Tip 1 - Practice Atleast 250 Questions
Tip 2 - Ex- Do atleast 2 projects
Tip 1 : Have some projects on resume.
Tip 2 : Do not put false things on resume.



A majority element is an element that occurs more than floor('N' / 2) times in the array.
A better solution is to use sorting. First, sort all elements using a O(nLogn) algorithm. Once the array is sorted, we can find all required elements in a linear scan of array. So overall time complexity of this method is O(nLogn) + O(n) which is O(nLogn).


Input: ‘N’ = 4, ‘NUMS’ = [2, 3, 6, 5]
Output: [3, 2, 6, 5]
At ‘i’ = 0, ‘NUMS[ i ]’ = 3
At ‘i’ = 1, ‘NUMS[ i ]’ = 2, it satisfies the condition ‘NUMS[ i ]’ <= ‘NUMS[ i - 1 ]’ if ‘i’ is odd.
At ‘i’ = 2, ‘NUMS[ i ]’ = 6, it satisfies the condition ‘NUMS[ i ]’ >= ‘NUMS[ i - 1 ]’ if ‘i’ is even.
At ‘i’ = 3, ‘NUMS[ i ]’ = 5, it satisfies the condition ‘NUMS[ i ]’ <= ‘NUMS[ i - 1 ]’ if ‘i’ is odd.
Observe that array consists of [n/2] even positioned elements. If we assign the largest [n/2] elements to the even positions and the rest of the elements to the odd positions, our problem is solved. Because element at the odd position will always be less than the element at the even position as it is the maximum element and vice versa. Sort the array and assign the first [n/2] elements at even positions.



For the given binary tree

The top view of the tree will be {10, 4, 2, 1, 3, 6}.
This approach does not require a queue. Here we use the two variables, one for the vertical distance of the current node from the root and another for the depth of the current node from the root. We use the vertical distance for indexing. If one node with the same vertical distance comes again, we check if the depth of the new node is lower or higher with respect to the current node with the same vertical distance in the map. If depth of new node is lower, then we replace it.
This round was pair programming round. In this round we code along with the interviewer. Interviewer will give us a typical system design question which we have to solve using OOPS.
Rent a Ride” As a customer to Rent a Ride you book a cab. We charge you as per the distance covered. We charge 8rs/km. The moment you click the button to RIDE, we search for the nearby drivers who will accept your ride. Suppose there are 15 drivers near your location, then we send the request to the first driver who is closest to you, then the second, and so on. There are a few conditions though, based on which we can not send the request to the nearby driver.
Condition 1: If the driver rating is lower than 4. (out of 5)
Condition 2: If you selected a specific car, and that car driver is not the closest one.
In case there is no driver present as per your request for the car, we will ask you to select some other car. A table was given having drivers, cars model, their ratings, and distance from the customer, and using this data we have to provide the most appropriate car to the customer, with the calculated fare. I was able to solve the problem in the given time, interviewers kept on asking questions about my code, and I answered every question. This round lasted 2 hours.
Always write a neat and clean code containing all the conditions. Use the variable names appropriately, the focus on them a lot. Make sure to use “Access modifiers wherever necessary”. Don’t forget to use a camel case

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?