풀이
시간 복잡도 : O(log n)
투포인터 풀이List A와 B 각각 포인터를 두고 각각 시작과 끝을 비교
Python
C++ 풀이
c++풀이
c++풀이
c++풀이
그리디 풀이 1.시작시간 기준 오름차순으로 정렬 2.현재 구간 시작시간이 이전 구간 끝 시간 이상인 경우 : 현재 구간 끝 시간으로 업데이트 겹치는 경우 : ans++ / 겹치는 두 구간 중 끝나는 시간이 느린 구간 삭제 => 현재 정렬된 상태에서 끝나는 시간 느릴수록
ㅇ
https://leetcode.com/problems/richest-customer-wealth/C++풀이
https://leetcode.com/problems/rotate-array/remainder(%) 사용 2.수학적 계산 풀이
https://leetcode.com/problems/best-time-to-buy-and-sell-stock/dp풀이1.int vi = i일 까지 최대 profit 저장 배열 2.index= 0(시작) 지점에서는 buy배열에 값 저장3.prices배열 마지막
https://leetcode.com/problems/find-all-anagrams-in-a-string/C++풀이1\. 알파벳을 hash table 구조 적용위해 vector res(26)선언 2\. for(auto c : p)resc-'a'++ =>
https://leetcode.com/problems/find-the-difference/C++ 알파벳 배열로 풀이법빠른 풀이(아스키코드의 합 비교 후 차이로 구하는 법)
https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/C++ 투포인터 풀이slow, fast 투 포인터 설정 (초기값 : 2 ->문제 조건 at most twice)slow = 새롭게 저장될
https://leetcode.com/problems/add-digits/C++ char<->int 변환 풀이char->int 바꾸는 방법 : (char)c-'0'더 빠른 풀이 (목과 나머지 관계 이용)
https://leetcode.com/problems/4sum-ii/c++ unordered_map 풀이시간제한 해결 위해 nums1,nums2 / nums3,nums4 각각으로 O(n^2)시간 복잡도1\. 처음 두 배열에 대해 unordered_map에 &
d
https://leetcode.com/problems/valid-parentheses/C++ stack(괄호)
큐를 사용한 BFS풀이 + 트리 노드예외처리) root가 nullptr로 들어오는 경우 {}반환