diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/longest_consecutive_sequence.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/longest_consecutive_sequence.cpp')
-rw-r--r-- | other/longest_consecutive_sequence.cpp | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/other/longest_consecutive_sequence.cpp b/other/longest_consecutive_sequence.cpp deleted file mode 100644 index 2fda5e6..0000000 --- a/other/longest_consecutive_sequence.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - int longestConsecutive(vector<int> &nums) { - unordered_set<int> us; - int ans = 0; - for (int i = 0; i < nums.size(); i++) - us.insert(nums[i]); - while (us.size() > 0) { - int num = *us.begin(); - int count = 1; - us.erase(num); - int smaller = num - 1; - int bigger = num + 1; - while (us.count(smaller) > 0) { - us.erase(smaller); - smaller--; - count++; - } - while (us.count(bigger) > 0) { - us.erase(bigger); - bigger++; - count++; - } - ans = max(ans, count); - } - return ans; - } -}; - -int main() { - Solution obj; - vector<int> nums = {100, 4, 200, 1, 3, 2}; - cout << obj.longestConsecutive(nums); -} |