Flipkart | PS/DS-1 Interview | 2 Questions asked

411
Oct 21, 2023

Question - 1: You are given a string sand an integer k and we repeatedly make not greater than k duplicate adjacent removals on s until we no longer can. Return the final string after all such duplicate removals have been made. It is guaranteed that the answer is unique. Sample Input:
s = aabbaaaba, k=3. Output: " "

Question - 2: Given a tree, print and remove the leaf nodes until the entire tree is empty. You cannot modify the tree. The order of output should be intact.
---->7
-->2
1
------>6
---->4
-->3
---->5
Output:
7 6 5
2 4
3
1

Comments (2)