Tip 1 : Practice Atleast 250 DS Questions
Tip 2 : maintain consistency while doing questions
Tip 3 : Do some projects
Tip 1 : Have some projects on resume.
Tip 2 : Do not put false things on resume.



A simple solution is to first count all elements less than or equal to k(say ‘good’). Now traverse for every sub-array and swap those elements whose value is greater than k. The time complexity of this approach is O(n2)
An efficient approach is to use the two-pointer technique and a sliding window. The time complexity of this approach is O(n)
Find the count of all elements which are less than or equal to ‘k’. Let’s say the count is ‘cnt’
Using the two-pointer technique for a window of length ‘cnt’, each time keep track of how many elements in this range are greater than ‘k’. Let’s say the total count is ‘bad’.
Repeat step 2, for every window of length ‘cnt’ and take a minimum of count ‘bad’ among them. This will be the final answer.



Input: NUM[] = {1,1,1,2,2,2}
Output: {1,2,1,2,1,2}
Note: {2,1,2,1,2,1} is also valid because there are no two adjacent which are the same.
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.
This round was pair programming round. In this round we code along with the interviewer. He/She will give us a typical system design question which we have to solve using OOPS.
The focus should be on following set of requirements while designing the parking lot:The parking lot should have multiple floors where customers can park their cars.The parking lot should have multiple entry and exit points.Customers can collect a parking ticket from the entry points and can pay the parking fee at the exit points on their way out.Customers can pay the tickets at the automated exit panel or to the parking attendant.Customers can pay via both cash and credit cards.Customers should also be able to pay the parking fee at the customer’s info portal on each floor. If the customer has paid at the info portal, they don’t have to pay at the exit.The system should not allow more vehicles than the maximum capacity of the parking lot. If the parking is full, the system should be able to show a message at the entrance panel and on the parking display board on the ground floor.Each parking floor will have many parking spots. The system should support multiple types of parking spots such as Compact, Large, Handicapped, Motorcycle, etc.The Parking lot should have some parking spots specified for electric cars. These spots should have an electric panel through which customers can pay and charge their vehicles.The system should support parking for different types of vehicles like car, truck, van, motorcycle, etc.Each parking floor should have a display board showing any free parking spot for each spot type.The system should support a per-hour parking fee model. For example, customers have to pay $4 for the first hour, $3.5 for the second and third hours, and $2.5 for all the remaining hours.
here is my take on it:
ParkingSlot > Floor > Parking
And separate FareController
So, a Parking can have many Floors and Floor and can have many ParkingSlots. Each Parking Slot is of certain slot size.
Vehicle is the interface type and all Vehicles just have to implement getType method to return type of Vehicle.
There is a separate enum for Slot size, and each slot size has the list of vehicle types it can accommodate. This keeps Parking and Vehicle objects independent of each other.
For calculating Fare, there is a separate FareController class which maintains map of each vehicle parked with details of parking and entry and exit time. Fare for Vehicle type can be kept in Parking and then getFare method can return the final fare on the basis of its inputs which is Parking, entryTime and exitTime.
DS algo and project related questions were asked


'm' and 'n' will always be odd.
Input: 'n' = 5, 'm' = 5
'mat' =
[ [ 1, 5, 7, 9, 11 ],
[ 2, 3, 4, 8, 9 ],
[ 4, 11, 14, 19, 20 ],
[ 6, 10, 22, 99, 100 ],
[ 7, 15, 17, 24, 28 ] ]
Output: 10
Explanation: If we arrange the elements of the matrix in the sorted order in an array, they will be like this-
1 2 3 4 4 5 6 7 7 8 9 9 10 11 11 14 15 17 19 20 22 24 28 99 100
So the median is 10, which is at index 12, which is midway as the total elements are 25, so the 12th index is exactly midway. Therefore, the answer will be 10.
An efficient approach for this problem is to use a binary search algorithm. The idea is that for a number to be median there should be exactly (n/2) numbers that are less than this number. So, try to find the count of numbers less than all the numbers



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).


The input string may contain the same characters, so there will also be the same permutations.
The order of permutations doesn’t matter.
A simple method is to create a Hash Table. Calculate the hash value of each word in such a way that all anagrams have the same hash value. Populate the Hash Table with these hash values. Finally, print those words together with the same hash values. A simple hashing mechanism can be modulo sum of all characters. With modulo sum, two non-anagram words may have the same hash value. This can be handled by matching individual characters
It was a leadership round they will touch up on some tech discussion and they will ask your interview experience along with previous organisation work experience.
He asked me about previous work experience in the internships.What kind of people I don’t like to work with? Biggest challenges faced by you and how you overcame them?
It was culture round where they ask your views about specific problem in society/company and how you can help to solve it and make society/company culture more inclusive
How comfortable do we feel working with LGBT+ community

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?