I am 2025 CS grad from Tier 3 , have applied to Hackerearth Problem Setter Intern position through Linkedin. I have immediately received a mail regarding online assessment. There were 3 dsa questions with a time limit of 1 hr 45 mins. The questions were 1 easy of leetcode level and two were of medium level.
Easy Question [20 points]
Given a string and an integer k, find the smallest character with kth largest frequency. If no such character found return -1.
Example: s = "aabcd" , k = 2 return 'b' as b is the smallest character among b,c,d which are of 2nd largest frequency.
Solved it by using sorting and using comparator.
Medium Question [50 points]
Given integers N , M and a matrix containing N x M pairs aij = {x,y} wherexandydenote the jump distance from current index i , j. Find the minimum number of steps required to travel from 0,0 to N-1,M-1.
Note : If current index is [i,j] , the jump can be to 8 possible cells :
[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] .
Solved it using BFS.
Medium Question [100 points]
Given n and two arrays a , b of size n, find number of pairs i,j where 0<=i,j<=n-1 such that gcd(a[i],b[j]) !=1.
Thought to solve it using algo similar to eratosthenes sieve but was not able to solve.
If anyone knows any approach of 3rd question you can feel free to share it in comments.