visited array is a good approach. The only thing that bothers me is "You must solve the problem without modifying the array nums and uses only constant extra space". I have only one option left "fast and slow pointer" often used to detect cycle in linked List.
For Each use case: where u want all elements, ex: In duplicate, you need every element.
visited array is a good approach. The only thing that bothers me is "You must solve the problem without modifying the array nums and uses only constant extra space". I have only one option left "fast and slow pointer" often used to detect cycle in linked List.
No comment, Let me fix it!