Modification: They just asked to tell the maximum number at that time.
I gave an approach that used sorting and unordered_map, they asked to optimize. I gave another solution using tries, which also uses sorting. They said okay, implement the first one, we will try to optimize it afterward if time permits.
I did that,andaskedifIcouldusemergesort, but they said merge sort consumes extra space, do that without using extra space. They wanted me to use the quick sort or heap sort.
In the end, they asked to optimize ( just the approach )
They gave 2 hints:
- Assign one number each for say a,b,c, etc, and multiply the min of each word. Then I said that yes if those numbers are prime, It will do the job.
In the end, they asked if I had any questions for them?
- Tell me something about yourself. Some concepts from OOPS:
- Can you declare an object of the same class type inside a class? And, some more good questions from OOPS.
- I did not answer many, so they said, Okay, tell anything. I said, “about oops”?
They said, yes.
3 coding questions:
They asked to implement it using graphs. I gave a dynamic programming approach