Watch and learn from other talented engineers while they’re solving coding interview questions on Pramp. In this session, the asked …



  1. I just saw the solution on google and found out that it is dificult.
    Goodluck for those who solved it..
    you are mathematically and progmatically Genius'!

  2. his approach about the second q was pretty boring approche is simply to compare first and the second element and call flip fuction with k =2 if false and repeat this process with the second and the third (after popping the first el , of course using a temporary array) and then repeat it with the third and the fourth …etc

  3. For the get a different number problem, one question is if [0,1,2], we return 3.
    What if we get [0,1,2,…,2^31-1], we cannot return 2^31 as it’s overflow.
    This is not going to happen. Constraints on the problem say length is 1 to 2^31-1, but number is from 0 to 2^31-1. That guarantees you find a solution that is <=2^31-1

  4. I think a nice follow up interview question would be to name a situation when such a scenario would ever be useful in real life. Immediately, I can think of a mechanical sorting machine. Hardware is expensive, software is cheap. In an effort to minimize cost, a mechanical sorting machine with 1 motor and 1 actuator could require such an algorithm.

  5. I'm a bit vocal about my opinions… I would likely say "its unreasonable to know this or need to know it at any point in the future. Furthermore, if you did have the desire to apply this knowledge you would be a bad engineer that should not be hired."

    edit: I know why these sort of questions are asked. I'm just saying this particular question is especially useless to ask or answer.

  6. I would fail this interview, for sure. But I've delivered everything I was asked for and more so far in my career, in several different types of projects and tech stacks. Congratulations if you are able to do this easily.

  7. unrealistic questions for a job, you dont do this in front of someone like this ever. its toxic gate keeping for people who dont work like this. if offensive that this is a thing. ask for code samples, give a challenge to solve alone. like on the job

  8. void pancakesort(int arr[]){

    int size=sizeof(arr)/sizeof(arr[0]);
    int i,j;

    for ( i = 0; i < size-1; ++i)

    for (j = 0; j < size-i-1; ++j)

    if (arr[j] > arr[j+1]){
    //in order to swap j th and j+1 th elememt we call flip fn three times


  9. Interesting Video Format. But sadly the sound cracks hurt my ears especially on headphones: Your Voices are so much more quiet so you raise the volume up and then the crack comes very loud.

    Sry but not very pleasant to hear.

  10. Before flipping in pancakeSort, you could also check if maxElementIndex == i, since if the greatest number is already in the end, no need to double flip the same pancake. Giving that solution a sorted array (example [1, 2, 3, 4]), would still call flip a total of 8 times (the last two calls are called with k=1, which just returns) and since flip also iterates the array, that becomes extremely heavy.

  11. Eu fiz a segunda em Lua / i did the second question in Lua
    parece certo? / seems correct?
    function getDifferentNumber(arr)

    tmp = {}

    for i = 1, #arr do

    tmp[arr[i]] = 0


    for i = 1, math.pow(2,31) – 1 do

    if not tmp[i] then

    tmp = nil

    return i




  12. there are jobs which need some deep knowledge like math or some specific feature of the programming language like threads. But many many programming jobs are just CRUD, business rules, reports… and the interviewers ask you a lotta tricks and math equation related questions that you won't use it in daily basis

  13. these are very simple problems and a decent programmer should be able to solve it in few mins without making stupid speculations and suppositions because interviewer is not gonna give you an hour. people who argue that "low-level problems like these can be solved through different libraries and students shouldn't waste their time on this stuff" have as tiny brain as these tiny problems because interviewer is suppose to see and judge your problem solving skills by watching you solve these problems, in majority cases they are not gonna give you a very large problem which is too complex to be solved in short amount of time

  14. Wouldn't a radix sort (for the second part in place, since we dont need stability) and then an iteration checking for the first gap be more efficient for the "Getting a different number" problem?

  15. Am I the only one that noticed that the pancakeSort method was never called in main()? The code never got tested. In this case fire the interviewer.

Leave A Reply

Please enter your comment!
Please enter your name here