Swiggy Interview Question for SDE-3s
- 0of 0 votes
Given multiple tuples in the form of (A,B) where A is the parent and B is the child in a binary tree, find if the input is valid or not. 4 error conditions were provided:- neer.1304 May 31, 2019 in United States
1. If a parent has more than 2 children,
2. If duplicate tuples entered,
3. If the tree has a cycle,
4. If more than one root possible.
For violation of multiple validity conditions, print the condition coming first in the above order.
If the input is valid, print the tree in a serial representation. For eg: If input is (A,B), (B,C), (A,D), (C,E) , output: (A(B(C(E)))(D))
| Report Duplicate | Flag | PURGE
Swiggy SDE-3 Algorithm
Open Chat in New Window