Tip 1 : Do DSA
Tip 2 : Do Extra Subjects
Tip 3 : Prepare some Projects
Tip 1 : Do Mention coding profiles in resume
Tip 2 : Do add summary of Projects
3 Questions
1st - Trees
2nd - Greedy
3rd - DP



You may assume that given ‘X’ and ‘Y’ definitely exist in the given binary tree.
For the given binary tree

LCA of ‘X’ and ‘Y’ is highlighted in yellow colour.
first i had stored parent array of root->node1 and root->node2 (to fins lca of node1 and node2)
then the first common element in path is lca
T.C -> O(n)
S.C -> O(n)



You are allowed to break the items.
If 'N = 4' and 'W = 10'. The weights and values of items are weights = [6, 1, 5, 3] and values = [3, 6, 1, 4].
Then the best way to fill the knapsack is to choose items with weight 6, 1 and 3. The total value of knapsack = 3 + 6 + 4 = 13.00
made the value array which is price/Wt array
sorted that array
Started Taking Element from last until bag is Full
T.C -> O(nlogn)
S.c -> O(n)



Here subset sum means sum of all elements of a subset of 'nums'. A subset of 'nums' is an array formed by removing some (possibly zero or all) elements of 'nums'.
Input: 'nums' = [1,2]
Output: 0 1 2 3
Explanation:
Following are the subset sums:
0 (by considering empty subset)
1
2
1+2 = 3
So, subset sum are [0,1,2,3].
firstly solved through recursion by exponential complexity
then memoized it.
Time complexity:- O(n*w)
I was asked 2 coding questions
1st -> Linkedlist
2nd -> Priority Queue


1. If the list is empty, the function immediately returns None because there is no middle node to find.
2. If the list has only one node, then the only node in the list is trivially the middle node, and the function returns that node.
I had used slow/fast pointer approach
slow pointer is moved by 1 dist and fast by 2
when fast ptr will reach null, slow will be at middle element



1. If 'x' == 'y', both stones are totally destroyed;
2. If 'x' != 'y', the stone of weight 'x' is totally destroyed, and the stone of weight 'y' has a new weight equal to 'y - x'.
I had taken the top 2 elements from priority queue and pushed their absolute difference back(if > 0)
and continued the process until one stone is remained in pq
T.C -> O(nlogn)
S.C -> O(n)

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
To make an AI less repetitive in a long paragraph, you should increase: