The G0CC15 was held on Hackerearth, there were two coding questions that needed to be completed in 60 minutes.
Question 1 : Count the number of N digit integer that are divisible by both X and Y.
Example : N = 2
X = 5
Y = 7
Output : 2
Explanation : The number of 2 digit integers that are divisible by both 5 and 7 is 2 (35 and 70).
Question 2 :
You are given a matrix of size N x N. Assign the letter 'a' an ID 1, 'b' an ID 2, and so on.
Here, A[i][j] denotes the value in cell(i,j) of matrix A denotes the cost of writing the letter
corresponding to ID j immediately after the letter corresponding to ID i.
Now, You are given a string S consisting of distinct lowercase alphabets and you have to
determine the minimum cost to generate any permutation of the given string.
Note: The cost of writing the first character is zero as no characters are present before the first character.
Example : N=5
0 5 1 5 3
4 0 9 4 2
7 9 0 10 7
1 2 8 0 2
3 9 7 7 0
S = abcde
Output : 8
Explanation : The permutation dbeac can be generated at a minimum cost of 8 as :
- cost of writing d = 0
- cost of writing b after d = 2
- cost of writing e after b = 2
- cost of writing a after e = 3
- cost of writing c after a = 1
Total cost = 0+2+2+3+1 = 8
*1st problem was relatively very easy. It took me quite some time to understand the 2nd problem,
I missunderstood it for the first time and I was unable to solve it.*
*If anyone is unable to understand the second problem leave a comment and I will help also
if you solve the second problem please post the solution *