Eat Study Love

먹고 공부하고 사랑하라

Python 187

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

Range Sum of Sorted Subarray Sums[M,Array,Two Pointers,Binary Search,Sorting]

https://leetcode.com/problems/range-sum-of-sorted-subarray-sums/description/?envType=daily-question&envId=2024-08-04You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.Return the sum of the numbers from index left to i..

Coding_Practice 2024.08.05

Merge k Sorted Lists[H,Linked List,Divide and Conquer,Heap ,(Priority Queue)Merge Sort]

https://leetcode.com/problems/merge-k-sorted-lists/description/You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.Merge all the linked-lists into one sorted linked-list and return it. Example 1:Input: lists = [[1,4,5],[1,3,4],[2,6]]Output: [1,1,2,3,4,4,5,6]Explanation: The linked-lists are:[ 1->4->5, 1->3->4, 2->6]merging them into one sorted list:1-..

Coding_Practice 2024.08.03

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

Linked List Loops(Python)

Linked list의 loop이 있는지 확인하는 건 1칸 씩 이동하는 slow와 2칸 씩 이동하는 Fast를 선언해서 T/F를 반환할 수 있었다고 알고 있었는데, 전체 list의 길이를 반환하는 거는 처음봤다. 일차적으로 내가 풀었을 땐 # Do not modify!class LinkedNode: def __init__(self, value): self.value = value self.next = None def hasLoop(head): if not head : return 0, True if not head.next : return 1,True slow = head fast = head.next cond = False while fast and f..

Coding_Practice 2024.08.02