The participants had to solve 2 coding challenges within a time period of 1 hour.
Question 1
You are standing at an infinite position axis grid and the starting position is (1,1).
The value in particaular position (i,j) in a grid is defined by the equation:
F( i , j )= i * j , where * denotes multiplication.
In one move , you can move from (i , j) to (i+1, j) or (i , j+1)
You are also given and integer N.
Now your task is to find the minimum number of moves needed to reach a position that contains the value N.
Input Format:
The first line contains an integer N.
where, 2<=N<=10^12
Output Format:
Print the minimum number of moves needed to reach a position that contains the value N.
Sample Test Case #0:
Input: 10
Output: 5
Sample Test Case #1:
Input: 25
Output: 8
Question 2
Given two arrays of length n
x = {x1, x2, x3,..., xn} and y = {y1, y2, y3,..., yn}
One operation consists of the following in order :
Find the minimum number of operations to convert X to Y. If impossible, return -1.
Constrainsts:
Input Format:
N
X[1] X[2].......X[N]
Y[1] Y[2]........Y[N]
Output Format:
Print the minimum number of operationsto make X equal to Y. If it is impossible return -1.
Sample Test Case #0:
Input:
3
1 2 3
1 2 3
Output: 0