Tip 1: Participate in daily contests on coding platforms. They are very helpful.
Tip 2: Complete at least two projects—one focused on the frontend and the other on the backend.
Tip 1: Mention only the things in your resume that you are sure about and have enough confidence in.
Tip 2: Include short and precise points in your resume, and do not include false information.
1. A word is a sequence of one or more lowercase characters.
2. Words are separated by a single whitespace character.
For the given string 'A' = “coding ninjas coding ninjas” and 'B' = “data structures and algorithms”, so both the word 'coding' and 'ninjas' are not present in string 'B' and occur two times each, but the word “coding” is lexicographically smaller than the word “ninjas”. So the answer is “coding”.
Brute force : The idea is to run a loop for each word and count the frequency of the word using a nested loop, and then print the word with highest frequency.
Optimized approach: Take a map and then run a loop and store each word into a map and then iterate into the map to check the frequency of each word.
N = 5
S = [‘aaa’, ‘bbb’, ‘ccc’, ‘aaa’, ‘bbb’, ‘aaa’]
ANSWER:- The answer should be ‘bbb’ as it is repeated 2 times and is the second most repeated word in the array [after the word ‘aaa’ which is repeated 3 times].
Count the frequencies of each word using the Counter function.
Traverse the frequency dictionary.
Check which word has a frequency of 2. If so, increase the count.
Print the count.
Step 1: I thought of a brute-force solution using maps and discussed it with the interviewer, but it was not good enough.
Step 2: The interviewer asked me to optimize the solution.
Step 3: I then provided a solution using recursion, but it still wasn’t good enough.
Step 4: The interviewer again asked me to optimize the solution.
Step 5: I then provided a solution using memoization, but the interviewer still asked me to optimize it further.
Step 6: Finally, I provided a solution using a top-down approach, and the interviewer was happy.
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?