Tip 1: Your data structure and algorithm basics should be very clear.
Tip 2: Try to solve questions in a specific time frame. Also, dry run your code with custom test cases and try to find the edge cases. Apart from this, try analyzing your solution's time and space complexity.
Tip 3: Take a look at editorials after solving the questions, as they can give you a better approach to the problem.
Tip 4: Pay attention to subjects like OOPs, DBMS, and OS. Interviewers ask a few questions from here as well.
Tip 1: Do not fake any skills, projects, or achievements. The interviewer gets to know about it by asking questions to you.
Tip 2: Have at least one good project on your resume with all the details like technologies used and purpose.
Sort the list in ascending order, then find the complement. After that, use a two-pointer approach with front and rear pointers to find the target value. Add the numbers to the result vector and ensure there are no duplicates by checking if the number is already in our list; if so, move the pointers.
Let’s say we have n=4 nodes, 'LEFT_CHILD' = {1, -1, 3, -1} and
RIGHT_CHILD = {2, -1, -1, -1}. So the resulting tree will look like this:
It will return True as there is only one valid binary tree and each node has only one parent and there is only one root.
I solved this question using preorder recursion in O(n) time
1. All the elements are in the range 0 to N - 1.
2. The elements may not be in sorted order.
3. You can return the duplicate elements in any order.
4. If there are no duplicates present then return an empty array.
If the number is visited, it is turned negative. If the visited number is negative, it means it has already been visited (duplicate) and is hence added to the list. Since the array values are from 1 to n, 1 is subtracted from the array values at the time of indexing.
An integer 'a' is closer to 'X' than an integer 'b' if:
|a - X| < |b - X| or ( |a - X| == |b - X| and a < b )
if X = 4, 3 is closer to 'X' than 9, as |3-4| < |9-4| i.e., 1 < 5 and if X = 4, 2 and 6 are equally close to it, as |2-4| == |6-4| = 2, but we say 2 is closer to 4 than 6, as 2 is smaller.
I solved this question using a heap data structure in O(nlogk) time.
This was an HR round that asked about personal experiences, expectations, and behavioral questions.
1. Where do you see yourself in next 5 years?
2. Why do you want to join?
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which keyword is used for inheritance?