Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Solution seems not necessarily to be that complicated..

Mandy Liu

Aug 28, 2023

class Solution: def findNumber(self, nums): smallest = 1 for num in nums: if smallest == num: smallest += 1 return smallest

2

0

Comments
Comments
Jan Carlos Dominguez
Jan Carlos Dominguez2 years ago

But this is without cyclic sort which I think is the whole point of the exercise.

Nhật Quang Trần
Nhật Quang Trần3 months ago

Your solution is incorrect for inputs like [3, 4, -1, 2, 1].

On this page