본문 바로가기

컴퓨터공학 & 정보통신87

[Basic] 기본 알고리즘 정리노트 간단하게 정리한 알고리즘 기법 정리 노트입니다. String Two pointers : 두 개의 피봇을 활용해 탐색하는 기법 (이중반복 -> 단일반복) / 배열 Sliding window : 고정 길이 Two pointers, 시간 복잡도 최소화 / 해쉬맵과 함께 활용 Prefix sum : 일종의 전처리 기법 Rabin Karp algoritm : 라빈 카프 알고리즘, 긴 스트링을 해싱하여 연산량을 축소 e.g.) 0번째문자ASCII * 2^2 + 1번째 문자 ASCII * 2^1 + 2번째 문자 ASCII * 2^0 Search BFS : graph, visitied, queue 활용 DFS : recursion Backtracking : DFS를 주요 활용하나 탐색 도중 조건에 부합하지 않는 경우를.. 2023. 2. 13.
[LeetCode] 167. Two Sum II - Input Array Is Sorted Two pointer 알고리즘을 활용하여 시간복잡도가 O(n) 이내가 되도록 문제를 풀어야 합니다. 본문 https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/ Two Sum II - Input Array Is Sorted - LeetCode Two Sum II - Input Array Is Sorted - Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers.. 2023. 2. 12.
[LeetCode] 438. Find All Anagrams in a String Sliding Window 알고리즘과 HashMap (파이썬에서는 dictionary로 구현) 자료구조에 대한 이해가 필요한 문제였습니다. https://leetcode.com/problems/find-all-anagrams-in-a-string 문제 핵심 일반적인 반복문 또는 Two pointer 기법을 사용하면 time limit 따라서 계산 횟수를 최소화 하는 기법을 사용해야 함 Two pointer 알고리즘과 비슷한 Sliding Window 알고리즘을 사용해야 한다 두 개의 해쉬맵을 만들어 계산을 간소화 솔루션 class Solution: def findAnagrams(self, s: str, p: str) -> List[int]: s_length, p_length = len(s), len(p).. 2023. 2. 12.