Eat Study Love

먹고 공부하고 사랑하라

코딩테스트 61

Median of Two Sorted Arrays[H,Array,Binary Search,Divide and Conquer]

https://leetcode.com/problems/median-of-two-sorted-arrays/description/Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.The overall run time complexity should be O(log (m+n)). Example 1:Input: nums1 = [1,3], nums2 = [2]Output: 2.00000Explanation: merged array = [1,2,3] and median is 2.Example 2:Input: nums1 = [1,2], nums2 = [3,4]Outp..

Coding_Practice 2024.08.12

Kth Largest Element in a Stream[E,Tree,Design,Binary Search Tree,Heap (Priority Queue),Binary Tree,Data Stream]

https://leetcode.com/problems/kth-largest-element-in-a-stream/description/?envType=daily-question&envId=2024-08-12Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.Implement KthLargest class:KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums.int..

Coding_Practice 2024.08.12

Minimum Number of Pushes to Type Word II[M,Hash Table,String,Greedy,Sorting,Counting]

https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-ii/description/?envType=daily-question&envId=2024-08-06 You are given a string word containing lowercase English letters.Telephone keypads have keys mapped with distinct collections of lowercase English letters, which can be used to form words by pushing them. For example, the key 2 is mapped with ["a","b","c"], we need to push ..

Coding_Practice 2024.08.06

Kth Distinct String in an Array[E,Array,Hash Table,String,Counting]

https://leetcode.com/problems/kth-distinct-string-in-an-array/description/?envType=daily-question&envId=2024-08-05A distinct string is a string that is present only once in an array.Given an array of strings arr, and an integer k, return the kth distinct string present in arr. If there are fewer than k distinct strings, return an empty string "".Note that the strings are considered in the order ..

Coding_Practice 2024.08.05

Make Two Arrays Equal by Reversing Subarrays[E,Array,Hash Table,Sorting]

https://leetcode.com/problems/make-two-arrays-equal-by-reversing-subarrays/description/?envType=daily-question&envId=2024-08-03You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.Return true if you can make arr equal to target or false otherwise. Example 1:Input: tar..

카테고리 없음 2024.08.03

Combination Sum - Back Tracking (Python)

Recursive는 컨디션 좋을 때 봐도 잘 모르겠다. 솔직히 완벽한 논리적 이해보단 이렇게 하면 되겠거니.. 하면서 느낌적으로 접근하는 경우가 많다. 답안을 봐도 헷갈리는데, 시험장에서 만나면 오죽하랴.. Recursive문제를 맘 먹고 꼬아서 내면 답이 없을 거 같다. 6. Combination Sum [7 pt]Given an array of distinct integers numbers and a target integer target, write a function combination_sum(numbers, target) to find all unique combinations in numbers where the candidate numbers sum to target. The same nu..

Coding_Practice 2024.08.02

Symmetric Tree[E,Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/symmetric-tree/description/Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Example 1:Input: root = [1,2,2,3,4,4,3]Output: trueExample 2:Input: root = [1,2,2,null,3,null,3]Output: false Constraints:The number of nodes in the tree is in the range [1, 1000].-100  Follow up: Could you solve it both recursively..

Coding_Practice 2024.07.31

Adding Spaces to a String[M,ArrayTwo Pointers,String,Simulation]

https://leetcode.com/problems/adding-spaces-to-a-string/description/You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at..

Coding_Practice 2024.07.26