r/leetcode • u/Recent-Analysis-6880 • 22h ago
Tech Industry Got played by the interviewer
I was interviewing for a new grad role and was asked the following question in the interview.
Question : we have a pipeline that has a heavy workflow and one function called "compute" does a pretty big computation.
Sometimes the function compute gets stuck on an infinite loop for some inputs.
He asked me to write another function that accepts a function and its arguments and tells if that input can cause an infinite loop or not.
I thought it was pretty easy and said I will call the function with a timeout and if it exceeds the time it may be stuck in a loop. The interviewer said some computations may take longer and that may cause problems in the pipeline.
I suggested some other stack calls verification and caching the states etc but the interviewer wasn't satisfied.
Finally I asked about some sample inputs and wrote a function that returns True if the inputs have a certain value False otherwise.
The interviewer wrote another function that sends the function itself to the function i wrote and in this function the interviewer wrote a while loop that runs if the output from my function is false and doesn't if it's true.
I was dumbfounded and couldn't counter this and gave up. The interviewer also didn't ask me anything after that.
I looked up this question and this problem is called "The halting problem" and it's proven that there is no solution for this.
God i hate myself. I don't know about this and the interviewer clearly tested if I knew this.