Tip 1: Practice on coding platforms.
Tip 2: Complete at least 3 projects.
Tip 1: Have at least 3 projects.
Tip 2: Avoid making any grammatical mistakes.



Step 1: I identified that the problem requires finding the longest substring where no characters repeat. This led me to consider using a sliding window approach to efficiently track and update the substring as I iterate through the string.
Step 2: I initialized two pointers, start and end, both set to the beginning of the string. I also used a set to keep track of the characters in the current window and a variable to store the maximum length of substring found.
Step 3: I started expanding the window by moving the end pointer to the right and adding characters to the set. If a character was already in the set (indicating a repetition), I moved the start pointer to the right until the repeated character was removed from the set, thus maintaining the condition of no repeating characters.
Step 4: For each step, I updated the maximum length of the substring by comparing it with the length of the current window (end - start + 1).
Step 5: After processing all characters, I returned the maximum length as the result. This approach had a time complexity of O(n), where n is the length of the string, as each character is processed at most twice.



str = "ababc"
The longest palindromic substring of "ababc" is "aba", since "aba" is a palindrome and it is the longest substring of length 3 which is a palindrome.
There is another palindromic substring of length 3 is "bab". Since starting index of "aba" is less than "bab", so "aba" is the answer.
Step 1: I recognized that the problem involves finding the longest substring that reads the same forwards and backwards. This can be efficiently solved using the "Expand Around Center" approach.
Step 2: I decided to use the "Expand Around Center" technique, where each possible centre of a palindrome (both single characters and pairs of characters) is considered, and the palindrome is expanded around this centre to find the longest possible palindrome.
Step 3: For each character (and each pair of adjacent characters) in the string, I expanded outwards while the characters on both sides of the centre were equal. I kept track of the start and end indices of the longest palindrome found during these expansions.
Step 4: I implemented a helper function to expand around a given centre and another function to iterate through each character and pair of characters, calling the helper function to check and update the longest palindrome found.
Step 5: I returned the longest palindromic substring after processing all possible centres.



For ‘N’ = 3,
All possible combinations are:
((()))
(()())
(())()
()(())
()()()
Step 1: I recognized that this problem involves generating all possible combinations of well-formed parentheses. Each combination must be balanced, meaning that every opening parenthesis ( must have a corresponding closing parenthesis ) and must be correctly nested.
Step 2: I decided to use a backtracking approach to generate the combinations. This technique involves building the solution incrementally and backtracking when a partial solution cannot be extended to a complete solution.
Step 3: I defined a recursive function that keeps track of the number of opening and closing parentheses used so far and the current combination of parentheses being formed. The recursion would build the combination step by step:
Base Case: When the combination length equals 2 * n (i.e., all pairs of parentheses are used), the combination is added to the result list.
Recursive Case: Add an opening parenthesis if we haven't used all n opening parentheses yet. Add a closing parenthesis if it does not exceed the number of opening parentheses used.
Step 4: I implemented the function using a helper function to handle the recursive backtracking and collecting results.
Hiring manager
HR Round

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?