Notice
Recent Posts
Recent Comments
Link
코딩 공부
코딩 인터뷰 퀘스천 완전 분석 - Two Sum 본문
[LeetCode] [Easy] 1. Two Sum
leetcode.com/problems/two-sum/
Two Sum - 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
주어진 배열안에 두 수의 합이 target 값이 나오는 index 구하기
1. Map을 이용하여 <nums[index], index>를 함께 저장한다.
2. for loop을 돌면서 target - nums[index]이 있는 곳을 찾으면 끝.
마지막 리턴은 딱히 할게 없어서 null을 써줬어요.
'Coding' 카테고리의 다른 글
코딩 인터뷰 퀘스천 완전 분석 - Find Lucky Integer in an Array (0) | 2020.10.13 |
---|---|
코딩 인터뷰 퀘스천 완전 분석 - Shuffle the Array (0) | 2020.10.13 |
코딩 인터뷰 퀘스천 완전 분석 - Move Zeroes (0) | 2020.10.12 |
코딩 인터뷰 퀘스천 완전 분석 - Add Strings (0) | 2020.10.12 |
코딩 인터뷰 퀘스천 완전 분석 - Valid Parentheses (0) | 2020.10.11 |
Comments