Catching up on a write-up for the C1 AI Engineer OA I did a while back, which I failed.
4 questions total, 1 hour 10 minutes.
The first two were really easy. I can't remember what they were, but they were just really easy, you can finish them in 10 minutes.
I didn't understand question 3, so I skipped it and went to do question 4, and in the end I had no time to come back to it, so it was completely blank. I remember it was a 2D matrix with 1s and 0s, and the 0s and 1s formed big X shapes.
Question 4 was: give you a list of numbers, [4, 123, 452, 321, 132, etc...], and ask how many pairs of numbers there are where swapping at most two digits makes one match another number in the input. I think you just, for each number, use two pointers to swap two digits, then check whether the result is in the input, and if it is, +1, and that's it. But while I was doing it my brain wasn't working. First I used backtracking to list out the permutations, then stored each number's permutations in a hash map to compare. After writing it I realized it was wrong, so I changed it to two pointers, but I overlooked that it's not at most two digits swapped for one number, it's at most two digits swapped for a pair of numbers.
Discussion
Loading comments…