Intern Software Engineer Interview Questions

9,357 intern software engineer interview questions shared by candidates

In Today’s class, Chef is here to teach students about Trees. Tree is a a connected graph of N nodes and N-1 edges. After class, Chef gave them an assignment to complete. Assignment is as follows :- Given a tree with single node (root), we need to find whether we can build a tree with exactly N leaf nodes by applying given queries. Query 1 : Choose any i in between 2 to K and any leaf node say L in current Tree, attach i leaf nodes to L. (We can choose any particular i only once) Query 2 : Choose an existing edge of Tree and cut the edge. Remove the entire sub-tree attached with that edge. Students need to answer T independent test cases. Can you help them ? Example • If K = 5, N = 6. One possible way to build a tree with N = 6 leaf nodes is :- o Query 1:1 = 5, leaf node = root. Now, there are 6 nodes in tree and 5 leaf nodes. o Query 1 : 1 = 2, choose any of the 5 leaf nodes. Now, there are 8 nodes in tree an leaf nodes. • If K = 2, N = 3. It is not possible to build tree with 3 leaf nodes using given queries. Function Description •K: Represents the maximum value of i allowed in Query 1. •N: Represents the required number of leaf nodes.
avatar

Associate Software Engineer Intern

Interviewed at Victoria's Secret

3.4
Apr 28, 2022

In Today’s class, Chef is here to teach students about Trees. Tree is a a connected graph of N nodes and N-1 edges. After class, Chef gave them an assignment to complete. Assignment is as follows :- Given a tree with single node (root), we need to find whether we can build a tree with exactly N leaf nodes by applying given queries. Query 1 : Choose any i in between 2 to K and any leaf node say L in current Tree, attach i leaf nodes to L. (We can choose any particular i only once) Query 2 : Choose an existing edge of Tree and cut the edge. Remove the entire sub-tree attached with that edge. Students need to answer T independent test cases. Can you help them ? Example • If K = 5, N = 6. One possible way to build a tree with N = 6 leaf nodes is :- o Query 1:1 = 5, leaf node = root. Now, there are 6 nodes in tree and 5 leaf nodes. o Query 1 : 1 = 2, choose any of the 5 leaf nodes. Now, there are 8 nodes in tree an leaf nodes. • If K = 2, N = 3. It is not possible to build tree with 3 leaf nodes using given queries. Function Description •K: Represents the maximum value of i allowed in Query 1. •N: Represents the required number of leaf nodes.

ROUND -1: Question 1: It was a 1600 rated ques on CF, exactly the same ( i found out later when i searched ). It was on Number Theory which included concepts of Primes, factors and modulus operator...i would say it was fairly easy, just needed to count the number of divisors of a particular num less than equal to a given num (something like that only).. Question 2: It was again a standard Sliding Window question, it is there on CSES, in which we are given to calculate the median of all the subarrays of size k in an array types... Qualifies this round, went to the final round.. FINAL ROUND: Question: It was mind - bending question on Trees, which included concepts of DP and MEX..later when i searched it on the internet, a similar ques was there on CF rated 3000..it was like i was given a tree, and among all the paths i needed the find the MEX of all, and then return the minimum MEX and something like that, if you'll serach these keywords on CF, i'm pretty sure you will get the question. So, got rejected in the Final Round!.
Aug 17, 2024

ROUND -1: Question 1: It was a 1600 rated ques on CF, exactly the same ( i found out later when i searched ). It was on Number Theory which included concepts of Primes, factors and modulus operator...i would say it was fairly easy, just needed to count the number of divisors of a particular num less than equal to a given num (something like that only).. Question 2: It was again a standard Sliding Window question, it is there on CSES, in which we are given to calculate the median of all the subarrays of size k in an array types... Qualifies this round, went to the final round.. FINAL ROUND: Question: It was mind - bending question on Trees, which included concepts of DP and MEX..later when i searched it on the internet, a similar ques was there on CF rated 3000..it was like i was given a tree, and among all the paths i needed the find the MEX of all, and then return the minimum MEX and something like that, if you'll serach these keywords on CF, i'm pretty sure you will get the question. So, got rejected in the Final Round!.

Viewing 6811 - 6820 interview questions

Glassdoor has 9,357 interview questions and reports from Intern software engineer interviews. Prepare for your interview. Get hired. Love your job.