BrowserStack Written Round Experience – Set 1

Hi, BrowserStack recently visited our campus for written test for December placements. The written round was conducted on HackerEarth and was of 3 hours and had 2 coding questions.

QUESTION 1:

JSON Prettier:-

Write a program which takes JSON as input and gives prettified JSON

You need to read JSON from STDIN. Input gives one line of uglified JSON.
Output should be formatted JSON. Check the standard output link.
Use 2 white spaces (not‘\t’) for one indentation.
SAMPLE INPUT:

{“group” : {list : [1,2,3]}, “list” : [“a”,”b”,”c”]}

SAMPLE OUTPUT:

{

“group” : {

List : [1,2,3]

},

“list” : [“a”,”b”,”c”]

}

EXPLANATION: Input will be uglifiedjson in one line and output will be prettified format of that.

QUESTION 2:

Given a string and a regular expression pattern, give the number of times the pattern occurs in the string. RegEx example means as follows:
. – 2 occurrences of the previous character
+ – 4 occurrences of the previous character
* – more than 5 occurrences of the previous character

Sample Input:
5
aaaaaannndnnnnnnfffhfhhgjjjwkkkllclc
a.
n+
a*
an.
a.d.

Sample Output:
5
3
2
1
0

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation