package
0.0.0-20241209140624-9fce2a725d55
Repository: https://github.com/elven9/my-leetcode.git
Documentation: pkg.go.dev
# README
Find All Duplicates in an Array
You must write an algorithm that runs in O(n) time and uses only constant extra space.
-> No hashmap ..
Solution Idx | Time Complexity | Space Complexity | Comment |
---|---|---|---|
1 | O(n^2) | O(1) | Two Pointer Scanning |
2 | O(n) | O(n) | Hashmap detector |
3 | O(nlogn) | O(1) | Sort and check duplicate |
4 | O(n) | O(1) | Using nums as frequency container using minus operator |