์ฝ๋ฉํ
์คํธ/LeetCode
2022. 7. 5.
[LeetCode] Longest Consecutive Sequence
๋ฌธ์ ๋งํฌ Longest Consecutive Sequence - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com ์ฃผ์ด์ง ์ซ์ ๋ฐฐ์ด nums์์ ๊ฐ์ฅ ๊ธธ๊ฒ ์ฐ์์ ์ผ๋ก ์ฐ๊ฒฐ๋ ์์ ๊ธธ์ด๋ฅผ ๊ตฌํ๋ ๋ฌธ์ ([1,2,3,4,5,7,8,9] => output = 5 (1,2,3,4,5)) ์กฐ๊ฑด : ์๊ฐ๋ณต์ก๋๋ ๋ฌด์กฐ๊ฑด O(n)์ดํ๋ก ์์ฑํด์ผํ๋ค. ์ฃผ์์ฌํญ : [1,2,2,2,3,3,4] ๊ฐ์ ๋ฐฐ์ด์ output์ด 2๊ฐ ์๋๋ผ 4์ด๋ค. ์ ๊ทผ ๋ฐฉ๋ฒ ์กฐ๊ฑด์ ๋ง์ถฐ ์ฃผ์ด์ง ๋ฐฐ์ด์ ๋จ ..