Anyone Can Solve the following Questions asked in a coding round.
Q1: Given two array A and B of length N find number of pairs whose gcd(A[i], B[j]) not equal to 1
Input: 2 -> N
2, 4 - >Array A
4, 2 -> Array B
Output: 4
Q2: Given N*M matrix contains pairs of integer (x, y). Intially you are standing at cell(1,1).Find the minium number o moves to reach cell (N, M) if not possible print -1
so if you are at cell (i, j) and pairs of integers at cell (x, y) then move to cell (i + x, j + y), (i + x, j - y), (i - x, j + y), (i - x, j - y), (i + y, j + x), (i + y, j - x), (i - y, j + x), (i - y, j - x).But you can't move outside the matrix.
Const: 1<= N, M <= 1000
Input: 6, 5
2 0 2 2 0 0 1 2 2 1
2 0 0 2 1 2 1 2 0 2
2 1 0 2 1 0 1 1 2 0
2 2 0 1 2 2 1 1 1 1
0 1 1 2 0 2 1 0 1 2
2 1 0 0 1 1 1 1 0 1
Output: 5
Q3: Given string s you need to find kth largest frequency character if two or more character are there print smallest one.
Input: aabcd
k = 2
here a: 2, b, c, d: 1 so output : b