I recently interviewed with Dunzo for SE-1 Backend role.
Q1.
Given an positive integer X and string S, where ‘0’ <= S[i] <= ‘9’
If int(S) % X != 0
Calculate the minimum number of deletions required in S, to make it divisible.
Constraints: len(S) <= 10000, X <= 100
Eg. S = “123456”, X = 13, here S % X != 0
By deleting 4 and 6 from the string
S = “1235” Now S % X = 0
So ans in this case is 2
-------------------------------------------Q2. Given a string of N length consisting of only lower case latin characters, Find lexicographically smallest subsequence of length exactly equal to X of this string.
Constraints:
1 <= N <= 1000000
1 <= X <= N.
‘a’ <= s[i] <= ‘z’Sample input:
N = 7, X = 5
String = “tourist”
Sample Output : orist
Among all other subsequence of length x=5, this “orist” subsequence is the smallest
of them all.