목록study/algorithm (37)
킴의 레포지토리
leetcode에서 278. first bad version 이라는 문제를 풀다가 이 문제가 git 명령어인 git bisect의 구현과 일맥상통한다는 것을 깨달았다. git bisect를 살펴보면 이진 검색이 실제로 어떻게 활용되는지 알 수 있어 이진 검색에 대해 더 깊은 이해가 가능하다.이 글에서는 1. 이진 탐색이 무엇인지 2. git bisect는 어떻게 사용하는지 3. git bisect 내부 구현은 어떻게 되어있을지 first bad version 문제를 통해 추론해보고 마지막으로 4.정리해보자.1. 이진 검색이란이진 검색이란이진 검색은 정렬된 값들 중에서 원하는 값을 찾기 위해 범위를 절반씩 줄여가며 값을 찾아가는 방식이다.숫자가 오름차순으로 정렬된 배열에서 26을 찾는다고 할때 이진 검색으..
📑 1. 문제 이해 https://leetcode.com/problems/kth-largest-element-in-an-array/?envType=study-plan-v2&envId=top-interview-150 Kth Largest Element in an Array - LeetCode Can you solve this real interview question? Kth Largest Element in an Array - Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not t..
📑 1. 문제 이해 https://leetcode.com/problems/word-search-ii/?envType=study-plan-v2&envId=top-interview-150 Word Search II - LeetCode Can you solve this real interview question? Word Search II - Given an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are leetcode.com ..
📑 1. 문제 이해 https://leetcode.com/problems/design-add-and-search-words-data-structure/?envType=study-plan-v2&envId=top-interview-150 Design Add and Search Words Data Structure - LeetCode Can you solve this real interview question? Design Add and Search Words Data Structure - Design a data structure that supports adding new words and finding if a string matches any previously added string. Implemen..
📑 1. 문제 이해 https://leetcode.com/problems/implement-trie-prefix-tree/?envType=study-plan-v2&envId=top-interview-150 Implement Trie (Prefix Tree) - LeetCode Can you solve this real interview question? Implement Trie (Prefix Tree) - A trie [https://en.wikipedia.org/wiki/Trie] (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of st..
📑 1. 문제 이해 https://leetcode.com/problems/minimum-absolute-difference-in-bst/ Minimum Absolute Difference in BST - LeetCode Can you solve this real interview question? Minimum Absolute Difference in BST - Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree. Example 1: [https://assets.l leetcode.com 이 문제는 이진..
📑 1. 문제 이해 https://leetcode.com/problems/kth-smallest-element-in-a-bst/description/?envType=study-plan-v2&envId=top-interview-150 Kth Smallest Element in a BST - LeetCode Can you solve this real interview question? Kth Smallest Element in a BST - Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree. Example..
📑 1. 문제 이해 https://leetcode.com/problems/binary-tree-right-side-view/description/?envType=study-plan-v2&envId=top-interview-150 Binary Tree Right Side View - LeetCode Can you solve this real interview question? Binary Tree Right Side View - Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Ex..
📑 1. 문제 이해 https://leetcode.com/problems/average-of-levels-in-binary-tree/description/?envType=study-plan-v2&envId=top-interview-150 Average of Levels in Binary Tree - LeetCode Can you solve this real interview question? Average of Levels in Binary Tree - Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10-5 of the actua..
📑 1. 문제 이해 https://leetcode.com/problems/sort-list/?envType=study-plan-v2&envId=top-interview-150 Sort List - LeetCode Can you solve this real interview question? Sort List - Given the head of a linked list, return the list after sorting it in ascending order. Example 1: [https://assets.leetcode.com/uploads/2020/09/14/sort_list_1.jpg] Input: head = [4,2,1,3] Output: [1, leetcode.com 💡 2. 알고리즘 설계..