Tip 1 : Graph should be on your tips.
Tip 2 : while explaining the solution to interviewer, dont just hop onto the most optimal solution. Start with the brute force one, give the cons of brute force solution, and then go step by step till you reach the optimal solution.
Tip 3 : Improve on your communication skills as well.
Tip 1 : Mention only what is required for your profile, for e.g. do not stress too much on your co curricular stuff. Rather, try explaining more of your technical stuff that is relevant for your job.
Tip 2 : keep it limited to 1 page. And make sure its a pdf and not an image.



In the below graph, there exists a cycle between vertex 1, 2 and 3.

1. There are no parallel edges between two vertices.
2. There are no self-loops(an edge connecting the vertex to itself) in the graph.
3. The graph can be disconnected.
Input: N = 3 , Edges = [[1, 2], [2, 3], [1, 3]].
Output: Yes
Explanation : There are a total of 3 vertices in the graph. There is an edge between vertex 1 and 2, vertex 2 and 3 and vertex 1 and 3. So, there exists a cycle in the graph.
A very popular floyd cycle detection algorithm.
1. Started with basic Hash map algorithms
2. Optimised with the floyd cycle algorithm.



1) Maximum root to leaf path sum for the subtree rooted under current node.
2) The maximum path sum between leaves (desired output).
For every visited node X, we find the maximum root to leaf sum in left and right subtrees of X. We add the two values with X->data, and compare the sum with maximum path sum found so far.



More details about Euler’s Totient Function can be found here
For ‘N’ = 10, if we take the array as 1, 2, 5, 10,
The Euler totient function value of 1 is 1.
The Euler totient function value of 2 is 1.
The Euler totient function value of 5 is 4.
The Euler totient function value of 10 is 4.
So, the summation will be 1 + 1 + 4 + 4 = 10.
Hence this is a valid array for ‘N’ = 10.
The solution will be verified by the actual value of the Euler Totient Function of 'N' and the sum of the Euler Totient Function of all the values returned. In the output, only the 'YES' or 'NO' is printed, according to the correctness of the solution.
The Euler's totient function, also known as Euler's phi function or simply phi function, is a mathematical function that calculates the count of numbers less than a given positive integer n that are coprime to n. In other words, it calculates the count of positive integers from 1 to n (inclusive) that are relatively prime to n, i.e., they do not share any common positive integer greater than 1 as a factor with n.



In the given linked list, there is a cycle, hence we return true.

Step 1 : For detecting loop I followed a two pointer approach, one slow pointer and one fast pointer. If two pointers meet, then there is loop
Step 2 : For finding the initial position of the loop, i started one pointer from the beginning and another pointer from the node they met while detecting the loop. The node where these two pointers meet again, the the initial position of the loop.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?