Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
695 views
in Online Assessments by Expert (108,170 points) | 695 views

2 Answers

0 like 0 dislike
Best answer
I applied for internship role batch 2023 via career page .
q1 -> given input M and N where n is length of string and m is index of lexicograhical sorted set of strings.
return the string of index M in lexicographical sorted set of strings . if index m is greater than the length of set of string then return "Not possible"

 

ex
n=2,k=3

 

AA
AB
BA
return BA

 

n=2,k=4
AA
AB
BA
HENCE NOT POSSIBLE

 

(I solved this problem using backtracking and passed the given test case there was only one test case)

 

q2-> C is number of cities F is number of flights. arry A is given where A[0] is starting city A[1] is destination and A[2] is price to travel from starting to destination .
return the price of the top 2 cheapest round trips as array. if there no possible round trip return infinity .

 

test case
4
6
0 1 20
1 0 60
1 2 10
2 0 10

 

op -
40
40

 

I was not able to solve this probelm and there was only 2 test case. so i wrote hardcode solution and passed the given test case .

 

update : I got email, i was not selected for further rounds.
by Expert (108,170 points)
0 like 0 dislike

Q2 can be solved using Dijkstra algorithm. Calculate ticket price from a city to all the cities (O(n*( V + E l o g V ) ) . Then check for the cheapest round trip in O(n^2).

 

it is a backtracking question. similar to https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/ but the only diffrence is insteed of abc we are taking abcdef... till n .

by Expert (108,170 points)

Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .