Eat Study Love

먹고 공부하고 사랑하라

Programming 51

My Calendar II[Array,Binary Search,Design,Segment Tree,Prefix Sum,Ordered Set]

https://leetcode.com/problems/my-calendar-ii/description/You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking.A triple booking happens when three events have some non-empty intersection (i.e., some moment is common to all the three events.).The event can be represented as a pair of integers start and end that represent..

Coding_Practice 2024.10.24

Remove Duplicates from Sorted List II[Linked List,Two Pointers]

https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/description/Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well. Example 1:Input: head = [1,2,3,3,4,4,5]Output: [1,2,5]Example 2:Input: head = [1,1,1,2,3]Output: [2,3] Constraints:The number of nodes in t..

Coding_Practice 2024.09.22

Rotate List[Linked List,Two Pointers]

https://leetcode.com/problems/rotate-list/description/Given the head of a linked list, rotate the list to the right by k places. Example 1:Input: head = [1,2,3,4,5], k = 2Output: [4,5,1,2,3]Example 2:Input: head = [0,1,2], k = 4Output: [2,0,1] Constraints:The number of nodes in the list is in the range [0, 500].-100 0 1. C또 Naive하게 했다가 얻어 맞은 Time Limit ㅠㅠC는 빠른 언어라 상관 없을 줄 알았는데 얄짤 없네/** * Definit..

Coding_Practice 2024.08.20

Find K-th Smallest Pair Distance[H,Array,Two Pointers,Binary Search,Sorting]

https://leetcode.com/problems/find-k-th-smallest-pair-distance/description/?envType=daily-question&envId=2024-08-14The distance of a pair of integers a and b is defined as the absolute difference between a and b.Given an integer array nums and an integer k, return the kth smallest distance among all the pairs nums[i] and nums[j] where 0  Example 1:Input: nums = [1,3,1], k = 1Output: 0Explanation..

Coding_Practice 2024.08.14

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

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

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