Tip 1 : Solve at least any standard interview preparation sheet
Tip 2 : Must prepare CS fundamentals like OOPS,OS DBMS at least
Tip 1: Atleast 2 good project should be in resume
Tip 2: Mention all your coding profile irrespective how many question you have done it that



Gcd of two numbers (X, Y) is defined as the largest integer that divides both ‘X’ and ‘Y’.
#include
using namespace std;
int GCD[1002][1002];
bool vis[1002][1002][2];
int dp[1002][1002][2];
void pre()
{
for ( int i = 1; i <= 1000; i++ ) {
for ( int j = 1; j <= i; j++ ) {
GCD[i][j] = GCD[j][i] = __gcd(i,j);
}
}
return;
}
int f(int a, int b, int turn)
{
if ( turn == 0 ) {
if ( a == 1 ) return 0;
}
if ( turn == 1 ) {
if ( b == 1 ) return 0;
}
if ( vis[a][b][turn] ) return dp[a][b][turn];
vis[a][b][turn] = true;
int ans = 0;
if ( turn == 0 ) {
ans |= (!f(a,b-1,turn^1));
if ( GCD[a][b] != 1 ) ans |= (!f(a,b/GCD[a][b],turn^1));
}
else {
ans |= (!f(a-1,b,turn^1));
if ( GCD[a][b] != 1 ) ans |= (!f(a/GCD[a][b],b,turn^1));
}
dp[a][b][turn] = ans;
return ans;
}
int main() {
int t,A,B;
pre();
cin >> t;
while ( t-- ) {
cin >> A >> B;
if(A==1 && B==1)
cout<<"Draw"< else if(A==1)
cout<<"Prateek"< else if(B==1)
cout<<"Gautam"< else{
if ( f(A,B,0) ) cout << "Gautam"< else cout << "Prateek"< }
}
return 0;
}



1. Delete a character
2. Replace a character with another one
3. Insert a character
Strings don't contain spaces in between.
I am used dynamic programming. I build a 2D matrix t[][] where t[i][j] represents the minimum number of operations required to transform the substring word1[0...i-1] into the substring word2[0...j-1].



Assume that the first and the last element of the array is -∞.
You are given ‘arr’ = [4, 6, 3, 2], Here element 6 is greater than 4 as well as 3, the index of 6 is 1. Hence the answer is 1.
First I told linear search solution then binary search one, then interviewer asked me to prove that you will always get a solution for binary search approach. I proved via contradiction method.



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 told using sorting. Then i used Min Heap approach. Interview was pretty happy in this.


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.
First I told brute force approach which interview told me to optimize then I wrote dp solution

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?