# Swiggy Interview Experience for SDE-1 | On-Campus 2021

• Difficulty Level : Medium
• Last Updated : 16 Dec, 2021

Eligibility

Branch: Open To all (No branch bias at all) (B.Tech + idd)

CGPA: 7.8

Verdict: Waitlist

Online Test: There were total of 4 questions.  (3dsa + 1sql)

Platform: HackerRank;

Time: 90 mins

1. https://www.geeksforgeeks.org/count-minimum-number-of-fountains-to-be-activated-to-cover-the-entire-garden/
2. Given a tree with each vertex having weight. In one operation you can choose any node, increase its weight by 1. Find minimum operations to convert tree into special tree. A special tree is tree such that for each vertex all of its adjecant vertex should have maximum difference <= 1.  (Hint: Try out bfs)
3. https://www.geeksforgeeks.org/number-substrings-count-character-k/. constraints n=1e5, k=100
4. SQL Question

Employee Table: {Emp id, Emp. Name, dept id}  & Department Table {dept id, dept name}

Result Expected:  dept name and corresponding count of employees. [Note: if there is no employee working in dept then print   “dept_name, 0”. Note dept name should be ordered decreasing by total employees working in that department, if it is same then in ascending dept id

```Emp_id, Emp_name, dept_id
1       hash           1
2       prash          1
3       cash           2
4       lash           3```
```dept_id   dept_name
1       Mechanical
2       Maths
3       Electrical
4       Physics```
```Output     Expected
Mechanical    2
Electrical    1
Maths         1
Physics       0```

Solution:

select d.name, count(d.id) from (department d inner join employee e on d.id = e.id) groupby d.id order by count(d.id) desc, d.name asc;

select concat(d.name + ” 0″) from (department d left join employee e on d.id = e.id) where e.id is null order by d.name asc;

Out of 295 appeared students, 30 got selected for interviews (Those Who have solved all the questions.) but you may expect yourself extended shortlist if you have not done only the SQ question.

Interview 1(Technical): There were 2 interviewer. The round was a basic DSA round.

1. Introduce Yourself
2. Given an array of size 2n (last n characters are zero) convert it to specified form

example [2, 3, 1, 5, 0, 0, 0, 0] convert it to [2, 2, 3, 3, 1, 1, 5, 5]

example [1, 4, 8, 0, 0, 0] convert it to [1, 1, 4, 4, 8, 8]

example [1, 0, 7,

0, 0] convert it to [1, 1, 0, 0, 7, 7]

it can be solved in O(1) space and O(1) time!

3. She “miscommunicated” the question as https://www.geeksforgeeks.org/find-closest-greater-value-for-every-element-in-array/ and wanted me to find O(n) solution which is not possible here!

My advice will be ‘keep talking what you are thinking’

So accidentally I said we cant use stack. She asked why? I told a sample test case on the above question. Then she corrected the question to  https://www.pepcoding.com/resources/online-java-foundation/stacks-and-queues/next-greater-element-official/ojquestion  This can be solved in O(n) time using stack. So keep talking you will keep getting hints.

4. https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/

Even though I have already solved this question thrice before the interview, still I could not code it. Please keep in mind that even the simpler questions seem to be pretty difficult in the tense situation of the interview. However I told the approach for the question (Recursion + left-right pointers) and they wrapped the interview, as we were already out of time.

5. Any Questions for us?

Interview 2(Technical): Tell me about yourself. Then we discussed my interest in Hockey.

1. Explain to me one of the projects.

I explained to him an Intern project on Recommender system+selenium(web scraping).

Why Selenium?

Challenges you faced in this project? (tell your own story)

What is the objective of this project? (I explained company purpose)

What different algorithms you use in this project(Matrix Factorisation, Collaborative Filtering, etc)

2. https://www.geeksforgeeks.org/given-a-string-find-its-first-non-repeating-character/

Initially I used two arrays of size 26.  First to count frequency of characters ‘a’ to ‘z’, second of size 26 to store index where the character ‘a-z’ occurs first.

He told me to get rid of the second array of size 26 and do it using only one array of size 26. I did it, using two times iterating the string.

3. https://www.geeksforgeeks.org/puzzle-bag-of-coins/ puzzle was asked. I acted as if I did not know and worked 5 mins on the question but he caught my acting. Tell me honestly if you know the puzzle already. LOL
4. Any Questions for us?

Result: Out of 25 students interviewed 3 students were selected for the main list, 1 student [b]me[/b] 🙁   selected for the waitlist. The waitlist was never promoted to the main list.

(Please note: There was no HR round)

All the best guys!!

My Personal Notes arrow_drop_up