Eat Study Love

먹고 공부하고 사랑하라

코테 31

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

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

Maximum Level Sum of a Binary Tree[M,Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on.Return the smallest level x such that the sum of all the values of nodes at level x is maximal. Example 1:Input: root = [1,7,0,7,-8,null,null]Output: 2Explanation: Level 1 sum = 1.Level 2 sum = 7 + 0 = 7.Level 3 sum = 7 + -8 = -1...

Coding_Practice 2024.07.31

Binary Tree Inorder Traversal[E,Stack,Tree,Depth-First Search,Binary Tree]

https://leetcode.com/problems/binary-tree-inorder-traversal/description/Given the root of a binary tree, return the inorder traversal of its nodes' values. Example 1:Input: root = [1,null,2,3]Output: [1,3,2]Example 2:Input: root = []Output: []Example 3:Input: root = [1]Output: [1] Constraints:The number of nodes in the tree is in the range [0, 100].-100 굉장히 기초적인 것이라고 생각했던 부분들인데 모르겠다아 짜증난다.. 1. P..

Coding_Practice 2024.07.31

Convert 1D Array Into 2D Array[E,Array,Matrix,Simulation]

https://leetcode.com/problems/convert-1d-array-into-2d-array/description/You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with  m rows and n columns using all the elements from original.The elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D ..

Coding_Practice 2024.07.26

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