Home
Elliot's dev hut
Cancel

Leetcode - 26. Remove Duplicates from Sorted Array

Link: https://leetcode.com/problems/remove-duplicates-from-sorted-array/ Introduction 입력으로 받은 배열 안의 중복된 데이터를 in-place로 제거하는 문제이다. 중복된 숫자들을 제거하고 앞에서부터 숫자를 채우면 되는데, 뒤쪽에는 어떤 숫자가 위치하든 상관없고, 중복없는 숫자의...

(WIP) Algorithm Basic - Dynamic Programming

Introduction Dynamic Programming은 알고리즘 중에서도 딱 하나로 정의가 되지 않는 알고리즘이다. DP와 관련된 내용을 인터넷에서 찾아보면 대부분 어딘가에서 가져와서 돌려쓰는 내용 복붙이 많다. (피보나치 멈춰!) DP를 쓰려면 점화식을 세워야 한단다. “음 그럼 점화식은 어떻게 세우죠? 어떤 규칙이 있나요?”라는 물음에...

Leetcode - Logest String Chain

Link: https://leetcode.com/problems/longest-string-chain/ Introduction LeetCode 오늘의 문제로 나오길래 풀어보니 이전에 이미 풀어본적 있는 문제였는데, 그 당시 정답을 보고나서도 이해를 잘 못하고 있었어서 그런지 제대로 기억이 안났다. 길이가 더 작은 단어에서 큰 단어로 찾아가면서 이...

Leetcode - Trapping Rain Water

Link: https://leetcode.com/problems/trapping-rain-water/ Introduction 그냥 우연히 펼친 파이썬 알고리즘 인터뷰 책에 전에 혼자서는 못 풀고 책에 있는 풀이의 도움을 받아 풀었던 문제가 있어서 다시 풀어보니 기억이 잘 안나서(제대로 이해를 못 했다는 뜻) 정리하게 됐다. Solution I....

Leetcode - Implement Trie (Prefix Tree)

Link: https://leetcode.com/problems/implement-trie-prefix-tree Introduction Trie 자료구조는 계속 정리해둬야지 하고 있었는데 마침 Leetcode에서 좋은 문제를 발견했다. arr = [‘A’, ‘to’, ‘tea’, ‘ted’, ‘ten’, ‘t’, ‘in’, ‘inn’]를 Tri...

Backtracking Basic - Combinations

Combinations 조합을 만드는 코드가 매번 짤 때마다 헷갈려서 그냥 한 번 정리해두기로 했다. 조합할 대상 iterables와 n을 인자로 받은 get_combinations()에서 사용하는 helper 함수에 들어 갈 것은 아래와 같다. iterables 조합할 대상 n 조합...

Leetcode - Check If a String Contains All Binary Codes of Size K

Link: https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k/ I. 문제 정의 Binary String인 s와 정수 k가 주어진다. k길이 만큼의 모든 binary code 조합의 리스트(ex: [‘00’, ‘10’, ‘01’, ‘11’] when...

(5/23) Leetcode - 알고리즘 면접 준비

121. Best Time to Buy and Sell Stock Link: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ class Solution: def maxProfit(self, prices: List[int]) -> int: answer, min...

(5/18) Leetcode - 알고리즘 면접 준비

Introduction 알고리즘 면접 준비를 하게 되면서 풀게 된 문제를 정리한다. 우선은 쉬운 문제들 부터 시작하는데 문제를 푸는 것만이 중요한게 아니라 논리적으로 납득할 만한 설명과 시간복잡도, 공간복잡도를 설명하는 것이 중요하다는 점을 배우게 됐다. 70. Climbing Stairs Link: https://leetcode.com/pro...

Leetcode - Longest Substring Without Repeating Characters

Link https://leetcode.com/problems/longest-substring-without-repeating-characters/ Introduction 주어진 문자열 s에서 반복되는 문자가 없는 가장 긴 부분 문자열을 찾는 문제이다. Note Index Out of Range 에러에 주의 Solution ...