Wednesday 6 October 2021

Apple Hacker Rank Test

Apple Hacker Rank Test

Apple Hacker Rank

Apple Hacker Rank Test

Q1 Connected Numbers

Numbers a and b are referred to as connected numbers if the digits in a can be replaced to get digits in b.
All occurrences of a digit must be converted at once. No two digits can be converted to the same digit.
If such a conversion is possible, print the minimum number of moves required for the conversion else print "Impossible".

Example1
Input
11223344 55227788

Output: 3

Explaination
Convert 1 to 5 -> 55223344
Convert 3 to 7 -> 55227744
Convert 4 to 8 -> 55227788

Example2
Input
1234 2334

Output: 2

Explaination
Convert 1 to 2 -> 2234
Convert 2 to 3 -> 2334

Q2 Frog in field can just to 6 different positions
2 up 1 left
2 up 1 right
2 down 1 left
2 down 1 right
2 left
2 right

Find minimum moves to reach insect.

Input
7 (dimension)
6 6 0 1 start (i, j) end (k, l)

Output
4

No comments :

Post a Comment