Open In App

Disney+ Hotstar ,SDE Intern 2023

Last Updated : 26 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The first round was a DSA round.

The interviewer asked for a brief introduction and jumped directly to the dsa problem. The first problem was a binary tree problem. The problem was – given a full binary tree and n (the total number of nodes), how can we find the number of nodes in the last level? The first basic approach I explained was the brute force level order traversal with space and time complexity of O(n). He, after listening to the approach, asked me if it could be optimized and if yes, how. After thinking for a couple of minutes, I did tell him that, we don’t need to store all nodes of that tree, so space complexity can be reduced to as low as O(1) (not considering the answer vector). He was happy but still asked for more optimization, which I expected from his end as the time complexity was unnecessarily high considering that I haven’t used that it is a full binary tree yet. Then after another couple of minutes of discussing my thoughts with him, I told him we could calculate the height, and the tree up to height -1 would be a complete binary tree and we know the total number of nodes in that would be calculated in O(1) as 1<<(h-1) where h is the height of complete tree. Deducting this number from n will give our answer. He was impressed as I told him it would take only O(h) or O(logn) time complexity to do this. He told me to code it. While coding I wrote the code for finding the height as usual for a binary tree which takes O(N) time, which he pointed and I corrected that by going only to the left child always. Overall this question was medium.

The second question was a DP problem. Given three arrays(a person can take multiple holidays), another array is the cost of each holiday and the other is the satisfaction. We have to maximize the satisfaction such that the cost remains less than a fixed number. I told him about the brute force approach and he asked if I could optimise it. After replying in the affirmative, he asked me for a new solution. I told it could be solved using the knapsack DP approach by iterating through the indices and picking or not picking it up and recursively calling the function and gave him a verbal pseudo code for it. He asked about the time and space complexity. The space complexity was approx, 2*N, which he said could be optimized further to N. I told him it was not much contributing as both are more or less the same to which he agreed and told me the interview was done and if I had any questions.

I, as it seemed he was satisfied, asked him what work he and his team did, and also how he felt about his interaction with me, and if there was anything I could work on. He said, he was satisfied and had an impressive interview and that, I would get a call from HR.

Selected for Hiring Managerial Round


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads