Skip to content
Related Articles

Related Articles

BrowserStack Interview Experience | Set 2 (Coding Questions)
  • Difficulty Level : Medium
  • Last Updated : 02 Jan, 2016

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.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.

My Personal Notes arrow_drop_up
Recommended Articles
Page :