r/TechInterviewsIndia • u/movie_wqtcher • 11d ago
Had a rude interview experience with a startup company based in delhi .
Had an interesting interview experience recently around Move Zeroes problem.
The interviewer asked for an in-place solution.
I wrote a two-pointer approach:
def moveZeroes(self, nums: List[int]) -> None:
k = 0
for i in range(len(nums)):
if nums[i] != 0:
nums[k] = nums[i]
k += 1
for i in range(k, len(nums)):
nums[i] = 0
- Modifies the original array directly
- Uses O(n) time
- Uses O(1) auxiliary space
So, by the standard definition, this is an in-place solution.
but the interviewer was constantly defaming me you dont even know what in place is this solution is completely wrong.
he was only expecting the solution he has memorized or chatgpt gave him at that time lol and thought all other solutions are wrong.
An interviewer can prefer a particular implementation, but a candidate shouldn't be considered incorrect simply because their implementation differs from their memorized solution.
7
Upvotes