BrowserStack Interview Experience | Set 2 (Coding Questions)

PROFILE: SOFTWARE ENGINEER
PAPER DURATION: 3 hours
NO. OF QUESTIONS: 2 (20 marks each)
MAXIMUM MARKS: 20*2 = 40 marks

QUESTION 1:
JSON Prettier:-

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

  1. You need to read JSON from STDIN. Input gives one line of uglified JSON.
  2. Output should be formatted JSON. Check the standard output link.
  3. 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:

XML parse plus series computation

Evaluate an expression given in XML format. Keys will be Expr- contains the entire expression. Elem – contains the digit, sum, Prod- contains two or more keys whose evaluation needs to be summed or multiplied respectively. Sub will contain 2 keys or more, where the second key onwards will have to be subtracted from the first one. Div- will contain 2 keys in which first key will need to be divided by second.

 

SAMPLE INPUT:

<expr>

<sum>

<elem>4</elem>

<elem>6</elem>

<elem>7</elem>

<elem>3</elem>

</sum>

</expr>

 

SAMPLE OUTPUT:
20

EXPLANATION:

Input will be xml file through standard input. End of xml file marked by </expr>.

If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.


Write your Interview Experience or mail it to contribute@geeksforgeeks.org



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.