코딩 공부

코딩 인터뷰 퀘스천 완전 분석 - Two Sum 본문

Coding

코딩 인터뷰 퀘스천 완전 분석 - Two Sum

Daily Coding 2020. 10. 10. 07:50

[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을 써줬어요.

 

Comments