본문 바로가기
반응형

LeetCode3

[LeetCode] 350. Intersection of Two Arrays II | LIM 문제 https://leetcode.com/problems/intersection-of-two-arrays-ii/ Intersection of Two Arrays II - LeetCode Can you solve this real interview question? Intersection of Two Arrays II - Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return leetcode.com Given two integer arrays.. 2023. 5. 3.
[LeetCode] 441.Arranging Coins | LIM 문제 https://leetcode.com/problems/arranging-coins/ Arranging Coins - LeetCode Can you solve this real interview question? Arranging Coins - You have n coins and you want to build a staircase with these coins. The staircase consists of k rows where the ith row has exactly i coins. The last row of the staircase may be incomplete. Give leetcode.com You have n coins and you want to build a staircase .. 2023. 5. 2.
[Algorithm] 투 포인터 (feat. leetcode Two Sum, Three Sum) | LIM 📚투 포인터 알고리즘이란 투 포인터 알고리즘은 리스트에 순차적으로 접근해야 할 때 2개의 점의 위치를 기록하면서 처리하는 알고리즘을 의미한다. 예를 들어서 2, 3, 4, 5, 6, 7번 학생을 가리켜야 할 때 우리는 '2번부터 7번까지의 학생'이라고 부르곤 한다. 이처럼 리스트에 담긴 데이터에 순차적으로 접근해야 할 때는 '시작점' 과 '끝 점' 2개의 점으로 접근할 데이터의 범위를 표현할 수 있다. 그냥 naive 방식인 반복문을 쓰다보면 시간 초과가 걸리는 경우에 투 포인터를 사용하면 메모리와 시간 효율성을 높일 수 있다. 포인터는 크게 두 가지 방식으로 쓰인다. 1. 앞에서 시작하는 포인터와 끝에서 시작하는 포인터가 만나는 형식 또는 원하는 값 target을 찾을 때까지 2. 또는 빠른 포인터(f.. 2023. 2. 19.
반응형