Interview Prep Day — 4
In continuation to below post
Today I started with Revision, revised all Java Interview questions, and did more questions related to JDBC, Spring, and Hibernate.
Then I solved leetcode questions including sudoku problem and rotate n*n array to 90 degrees. Solved would be wrong here as I had to cheat from various blogs at the end, and I will add these both questions to do again.
I started with solving the leetcode challenge which was finding if given two trees are the same. I solved it recursively checking if data of the first and second trees are the same by traversing all left and right nodes till not null. Returning false in case data don’t match.
Rest of the questions I solved today was from leetcode top interview coding questions
Strings
Given two strings s and t, write a function to determine if t is an anagram of s.
An anagram is basically, having all the characters in s which are present in string s.
It took hashmap storing the frequency of all the characters in string s and then comparing it with string t. If char doesn’t exist in string t return false, else return true.
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
A palindrome is a word, phrase, or sequence that reads the same backward as forwards
For solving this I can take 2 pointers, One is START as the 0 and the other is END as the length of string, but there is a catch before taking the end pointer, we need to replace all the empty spaces and punctuation marks. And after removing all the extra space take the END as the length of current string, now iterate over this string while START is less than END. If string[START] != string[END] return false else do START++ and END — —
Longest Common Prefix
was another question I tried to do but didn’t get any optimized solution. Will do this tomorrow.
Except for this, I read MySQL Internals book, I consider this also as my interview preparation in terms of System Design.
May All of you get your dream Company. I will be soon in my dream company.😊
Happy Learning!!!