GFG App
Open App
Browser
Continue

# Zomato Interview Experience for SDE-2

Round 1(Problem Solving+Discussion on Past Work 1.5hrs)

1. Reverse words in a sentence. Two words are separated by one or more spaces

Example:

`"ab cd    efgâ€ť -> â€śba dc   gfeâ€ť`
2. Given a sorted array containing duplicates and a key, find the frequency of the key in the array

Example:

`[1,1,1,2,2,2,2,3,3,4,4,4,4] and key = 2 => Frequency = 4`

Round 2(Design+Discussion on Past Work 1.5hrs)

• Users can view/post tweets
• Users can follow other users
• Generate Newsfeed for a User
2. Given a pair of x, y values sorted by x, use the below equation to output the values sorted by y.

```y = 3x2 + 3x - 36
T
x, y
-1000,
-900
-825
â€¦
â€¦ 0
40,
70,0
â€¦```

Hint: The given equation is of an upward parabola, thus there will be a minimum. As the input is sorted by x, after finding the minima, sorting by y can be done by having two pointers traversing on both sides of the minima)

3. Given two arrays, where if a value is present in both the array, you can switch b/w arrays, find the maximum sum.

```Input: ar1[] = {2, 3, 7, 10, 12, 15, 30, 34}
ar2[] = {1, 5, 7, 8, 10, 15, 16, 17}
Output: 122```

In the above input, since both arrays contain 7, at 7, you can switch from ar1- > ar2 and vice versa

My Personal Notes arrow_drop_up