Tip 1 : Make sure to solve a standard interview preparation sheet as part of your preparation.
Tip 2 : Ensure to thoroughly prepare Computer Science fundamentals such as Object-Oriented Programming (OOPS), Operating Systems (OS), and Database Management Systems (DBMS) at the very least.
Tip 1 : Ensure your resume includes at least two substantial projects.
Tip 2 : Include all your coding profiles, regardless of the number of questions you have completed in each of them.



Gcd of two numbers (X, Y) is defined as the largest integer that divides both ‘X’ and ‘Y’.
The pre() function calculates the GCD for all pairs of numbers from 1 to 1000 and stores the results in the GCD array.
The f() function is the main recursive function to calculate the winning state of the game for both players. It uses memoization (through the vis and dp arrays) to avoid redundant calculations.
The main() function takes the number of test cases as input and runs a loop for each test case. For each test case, it takes input values A and B, representing the two numbers for that game.
If both A and B are equal to 1, the game results in a draw. If A is 1 and B is not, Prateek wins. If B is 1 and A is not, Gautam wins.
For other cases, it calls the f() function to determine the winner.
The algorithm effectively simulates the game and calculates the winner based on the given A and B values.
Note: It is essential to include the necessary header files ( and ) at the beginning of the program.



1. Delete a character
2. Replace a character with another one
3. Insert a character
Strings don't contain spaces in between.
I employed dynamic programming to construct a 2D matrix, denoted as t[i][j], where each entry represents the minimum number of operations needed to transform the substring word1[0...i-1] into the substring word2[0...j-1].



1. There are no 2 adjacent elements having same value (as mentioned in the constraints).
2. Do not print anything, just return the index of the peak element (0 - indexed).
3. 'True'/'False' will be printed depending on whether your answer is correct or not.
Input: 'arr' = [1, 8, 1, 5, 3]
Output: 3
Explanation: There are two possible answers. Both 8 and 5 are peak elements, so the correct answers are their positions, 1 and 3.
Initially, I presented a linear search solution, and then I proposed a binary search approach. Subsequently, the interviewer requested me to demonstrate that the binary search approach will always yield a solution. To prove this, I utilized the contradiction method.



I used tabular dp



Let ‘N’ = 4, ‘Arr’ be [1, 2, 5, 4] and ‘K’ = 3.
then the elements of this array in ascending order is [1, 2, 4, 5]. Clearly, the 3rd smallest and largest element of this array is 4 and 2 respectively.
First, I suggested using the sorting technique. Later, I introduced the Min Heap approach. The interviewer expressed satisfaction with both solutions.



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.
Initially, I presented the brute force approach, but the interviewer requested an optimization. Subsequently, I provided a dynamic programming solution as an improved alternative.

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