Leetcode 279

[Binary Search][Easy] 35. Search Insert Position

https://leetcode.com/problems/search-insert-position/description Search Insert Position - LeetCode Can you solve this real interview question? Search Insert Position - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must w leetcode.com Q. 주진 정렬된 배열 nums에서 target val..

[Binary Search][Medium] 34. Find First and Last Position of Element in Sorted Array

https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/description Find First and Last Position of Element in Sorted Array - LeetCode Can you solve this real interview question? Find First and Last Position of Element in Sorted Array - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next ..

[Binary Search][Hard] 4. Median of Two Sorted Arrays

https://leetcode.com/problems/median-of-two-sorted-arrays/description Q. 주어진 정렬된 array nums1과 nums2가 주어질 때, 두 array를 정렬하여 합친 array의 median 값을 구하라. 이때 TC가 O(log(m+n)) 이 되도록 하라. Solution. 우선 median 값의 정의부터 알 필요가 있겠다. 어떤 array의 가운데 위치의 값을 뜻하는데, 길이가 홀수이면 그 중앙 값을 취하면 되겠지만, 짝수일 때는, 인접한 중앙값 두 개의 평균을 구하면 되는 것이다. 즉, index상 중앙에 위치한 값들에 의해 결과가 정해진다. 우선 간단하게 두 정렬된 array들을 merge sort 해 본다. 이후 중앙 값을 median 값을..

[Backtracking][Medium] 131. Palindrome Partitioning

https://leetcode.com/problems/palindrome-partitioning/description Palindrome Partitioning - LeetCode Can you solve this real interview question? Palindrome Partitioning - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Q. 주어진 문장 s 에 대해, 파티션으로 문자를 나눈다. 이때 이 나눠진 문자(sub string) 모두가 palindrome ..

[Backtracking][Medium] 79. Word Search

https://leetcode.com/problems/word-search/description Word Search - LeetCode Can you solve this real interview question? Word Search - Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are h leetcode.com Q. 주어진 board와 word에서 해당 board 안에 word가 있는지 여부를 반환하라..

[Backtrack][Medium] 78. Subsets

https://leetcode.com/problems/subsets/description Subsets - LeetCode Can you solve this real interview question? Subsets - Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: n leetcode.com Q. nums 배열이 주어질때, blank를 포함한 해당 배열로 조합 가능한 모든 subset을 찾아라. Sol..

[Backtracking][Hard] 51. N-Queens

https://leetcode.com/problems/n-queens/description N-Queens - LeetCode Can you solve this real interview question? N-Queens - The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You ma leetcode.com Q. n-queens 퍼즐에 맞게 Q 를 n x n 체스보드에 맞게 배치하여라. Solution. 역시..

[Backtracking][Medium] 46. Permutations

https://leetcode.com/problems/permutations/description LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Q. 주어진 배열 값 nums 가 있을 때, 이 배열로 조합 가능한 모든 조합을 출력하라. Solution. 좋은 문제임과 동시에 실제 많이 접할 수 있는 문제. 모든 수 조합을 하나씩 넣어보고, 유일한 조합인지 확..

[Backtracking][Medium] 39. Combination Sum

https://leetcode.com/problems/combination-sum/description LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Q. 정수 배열인 candidates 와 target 이 주어질 때, 그 합이 target이 되는 유일한 candidates 조합들을 모두 찾아라. Solution. Backtrack의 기본은 모든 원소를 순회..