Tip 1: Practice solving DSA problems on various coding platforms.
Tip 2: Try building projects using emerging technologies like AI/ML, Neural Networks, Deep Learning, Cloud Computing, etc.
Tip 3: Solve problems related to all types of Data Structures.
Tip 1: Do not include false information on your resume.
Tip 2: Try to create a one-page resume and include only your practical work.
Date & Time: 6-hour window open from 3:00 PM on 24th Dec 2023 to 3:00 PM on 25th Dec 2023.
A total of 6 medium to hard-level DSA questions were provided.
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong
order. The problem with bubble sort is its worst case scenario. When the smallest element is in the last position, then it
takes more time to sort in ascending order, but takes less time to sort in descending order.
An array is called beautiful if all the elements of the array are in either ascending or descending order.
Given an array of numbers, find the minimum swap operations required to make the array beautiful.
Constraints
0 < N < 1000
0 < Arr[i] < 1000
Input :
First line contains of integer N denoting number of elements in the array.
Second line consist of N integers separated by space denoting the elements of the array.
Output :
Single integer denoting the least numbers of swap operations required to make the array beautiful.
Time Limit (secs)
1
Example 1
Input :
5
4 5 3 2 1
Output :
1
Explanation :
The number of swaps required to sort the elements in ascending order is 9.
The number of swaps required to sort the elements in descending order is 1.
The best way is to sort in descending order and swaps required is 1.
I used bubble sort sorting algorithm to solve this problem. I counted the total no. of swaps required for sorting the array in ascending order And descending order. Then find the minimum in both asending & descending swaps.
Date & Time: 6-hour window from 3:00 PM on January 19, 2024, to 3:00 PM on January 20, 2024.
A total of 8 medium to hard-level DSA questions were present.
// Getaway Gala
// Problem Description
At the annual office holiday party, excitement buzzed as employees gathered for a lucky draw. Among the prizes was a weekend getaway voucher.
With a small number of attendees forming a row, the organizer chose to forego the conventional lucky dip approach. Instead, they introduced a more curious and engaging method that will eliminate every employee except one, who is considered as winner.
The organizer aimed to eliminate employees in two rounds. In the first round, he will form a row of employees who participated. Then he will select the first letters of all the employees from left to right and form a string S. Then he will start eliminating the employees whose name is forming the palindrome (every time he will delete the first name from left to right which is forming a palindrome). He will continue this process till the string S does not have any sub strings which are palindromes.
For example, consider the names {Hari Giri Siri Gopi Hima} in the row. Here the string S formed by picking the first letter of the names is HGSGH. Note that substring GSG is a palindrome .When processing from left to right, the alphabet G from the name Gopi forms a palindrome. We call the name Gopi as Mirror Word. Hence we eliminate Gopi in the first iteration.
Now only names {Hari Giri Siri Hima} remain. String S is HGSH which does not have any palindrome. Hence the final row will be {Hari Giri Siri Hima}. If string S had more palindromes we would apply the same procedure as mentioned in paragraph above. Since string S is now palindrome free, the organizers will now apply a different criteria.
This criteria will be to remove every Nth person from the remaining names everytime processing the names from left to right. The last name remaining is the winner of the lucky draw.
Given the list of names of employees, and the value of N, find out the who the winner is.
// Constraints
Names comprise of upper and lower case characters. Processing is case insensitive.
1 <= number of employees <= 1000
1 <= N <= 1000
1 <= length of name <= 10
// Input
First line consists of an array indicating the names of employees present in the row. Names are space separated.
Second line consists of a single integer N denoting the interval of elimination.
// Output
Print the name of the employee who is going to be the winner. Print the name as it is given in the array.
// Time Limit (secs)
1
// Example 1
// Input
Janu gita sana gopi jaslin Tony Ritu Naina sonu Neha
2
// Output
Janu
// Explanation
As we can see, gopi is forming a mirror word according to the given rules, thus we eliminate the employee named gopi. Now gopi's position will be empty. Again, the name Neha is forming mirror word, hence we remove the name Neha and the resulting row will be {Janu gita sana jaslin Tony Ritu Naina sonu}. Now there can be no palindromes after picking the first alphabets of the remaining names. Hence the second criteria is now applied where N is 2. Now, processing from left to right, if we start removing every 2nd name (Nth name) until we are left with one person, then it turns out that Janu will be the winner, hence print "Janu".
Firstly I Create a string 'sb' using starting letter of each employee.
For each string in the list, create substrings of 'sb' up to length j + 1 (sb.substr(0, j + 1)).
Convert the substring to uppercase using transform.
Check if the substring is a palindrome using checkPalindrome() function.
If it is a palindrome:
Remove the current string from the list using list.erase(iterator).
Remove a character from sb using sb.erase(j, 1).
Update counters n and j to reflect the changes.
If not, move the iterator forward (++iterator).
After the palindrome-based removal, a eliminates every Nth string until only one is left:
Use list.erase(list.begin() + (N - 1)) to remove the Nth string from the list.
Decrement size to reflect the reduced list size.
2 DSA-based coding questions, medium to hard level, for 90 minutes.
There are 3 different types of balls (Green, Yellow, Red) having frequency x, y, z.
Then return the no. of ways of arranging this balls into straight line such that adjacent balls always have different colours.
Ex. 1 :
Input : G=1, Y=1, R=0
Output : 2
Explanation : GY & YG
Ex. 2 :
Input : G=1, Y=1, R=1
Output : 6
Explanation : GYR, GRY, RGY, RYG, YGR, YRG
I created a recursive function for finding output & do Backtracking to place balls iteratively while checking adjacency.
Check if any of the counts x, y, z are greater than the sum of the other two combined. If true, no valid arrangement is possible. And I used permutations and recursive generation to count all valid arrangements that satisfy the adjacency condition.
The countArrangements() function recursively tries placing each type of ball while checking the last color placed to avoid adjacency violations.
The noOfArrangements() function initializes the count and calls the helper function.
The interview panel consists of 3 members who will ask technical questions (based on DSA, OOPs, DBMS, Software Engineering), HR and MR questions, and discuss the project.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which SQL keyword removes duplicate records from a result set?