Tip 1 : 1D Array and 2D array problems.
Tip 2 : Puzzle solving
Tip 3 : Your projects.
Tip 1 : Projects should be on relevant tech stacks.
Tip 2 : Your achievements should be highlighted.
4 easy coding problems and 30 mcq's.



The given linked lists may or may not be null.
If the first list is: 1 -> 4 -> 5 -> NULL and the second list is: 2 -> 3 -> 5 -> NULL
The final list would be: 1 -> 2 -> 3 -> 4 -> 5 -> 5 -> NULL
Maintain a head and a tail pointer on the merged linked list.
Then choose the head of the merged linked list by comparing the first node of both linked lists.
For all subsequent nodes in both lists, you choose the smaller current node and link it to the tail of the merged list, and moving the current pointer of that list one step forward.
You keep doing this while there are some remaining elements in both the lists.
If there are still some elements in only one of the lists, you link this remaining list to the tail of the merged list.
Initially, the merged linked list is NULL.
Compare the value of the first two nodes and make the node with the smaller value the head node of the merged linked list.
Since it’s the first and only node in the merged list, it will also be the tail.
Then move head1 one step forward.




If we are given the above binary tree as input then moving from root node(5) to the farthest leaf node(50), the path formed will be [ 5->10->25->35->40->45->50 ]. The total number of nodes encountered is 7, therefore the maximum depth of the binary tree is 7.
Let's redefine the problem:
So, the question says given the root of a binary tree, return the maximum depth of the tree. Max depth means the number of nodes along the longest path from root to farthest leaf node.
Recursion:
Lets have faith in recursion and assume that we are already given the maximum depth of root's left and right subtrees by recursion.
So to find the maximum depth of this binary tree, we will have to take out the maximum of the 2 depths given to us by recursion, and add 1 to that to consider the current level i.e. root's level into our depth.
So basically, to find the maximum depth of the binary tree given, we mainly have to have do
int maxDepthLeft = maxDepth(root->left);
int maxDepthRight = maxDepth(root->right);
return max(maxDepthLeft, maxDepthRight) + 1;
Base Case:
We can easily analyze that if we are at a leaf node as root, then its left and right subtrees will have 0 depth, and consecutively, this leaf node will have max depth of 1.



Floyd’s Cycle-Finding Algorithm // fast slow approach // 2 pointers // "tortoise and the hare algorithm"
Approach: This is the fastest method and has been described below:
Traverse linked list using two pointers.
Move one pointer(slow_p) by one and another pointer(fast_p) by two.
If these pointers meet at the same node then there is a loop. If pointers do not meet then linked list doesn’t have a loop.



You do not need to print anything, just return the head of the reversed linked list.
If Head is null,then there's No Linked list to reverse, return null or head itself.
After reversing the linked list, Last Node must point to null ptr.
till tempNode reach to the last Node and traverse the whole linkedlist.
store the address of the next node to traverse
reverse the direction of the link arrows
store the address of the present temp node into prev
now move the ptr(tempNode) to the next Node.
after reversing Last Node is the first one and behave like a head Node
Questions from oops, programming, projects, puzzle solving.
We have two water jugs, one measures 4 Gallons (4G) while the other measure 9 Gallons (9G). But there is no measuring label mentioned on either of these two jugs i.e. we cannot know the exact amount filled in the jug. Now, assuming there is an infinite amount of water supply, can we measure all 1G, 2G, 3G…….. upto 9G using these unmarked jugs.
Tip 1: Practice a lot on different platforms
Tip 2: use stopwatch to measure your speed.




- set k = 0, l = 0
set m = n, value = 1
initialize 2D result as vector>
/*
k - starting row index
m - ending row index
l - starting column index
n - ending column index
i - iterator
*/
- loop while k < m && l < n
- loop for i = l; i < n; i++
- set result[k][i] = value
- increment value++
- k++
- loop for i = k; i < m; i++
- set result[i][n - 1] = value
- increment value++
- n--
- loop for i = n - 1; i >= l; i--
- set result[m - 1][i] = value
- increment value++
- m--
- loop for i = m - 1; i >= k; i--
- set result[i][l] = value
- increment value++
- l++
- return result

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?