educative.io

Problem statement / solution is wrong

We’re asked to solve it in constant space O(1), but the provided solution is linear space O(N). Either change the solution or the statement to clear this up


Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Find all Duplicate Numbers (easy) - Grokking the Coding Interview: Patterns for Coding Questions

Hi @Nicolas_F ,

Ignoring the space required for storing the duplicates, the algorithm runs in constant space O(1). The time complexity of that algorithm is O(n), not the space complexity.

We hope Educative has inspired you to further your learning. :slight_smile:

exactly, if you ignore the space required for storing the duplicates will make any solution to any problem constant space O(1). it’s like saying you won’t ingest calories if you remove the apple before eating an apple.


Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Reverse a Sub-list (medium) - Grokking the Coding Interview: Patterns for Coding Questions