Eat Study Love

먹고 공부하고 사랑하라

파이썬 39

Maximum Depth of Binary Tree(Tree,Depth-First Search,Breadth-First Search,Binary Tree)

https://leetcode.com/problems/maximum-depth-of-binary-tree/description/Given the root of a binary tree, return its maximum depth.A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example 1:Input: root = [3,9,20,null,null,15,7]Output: 3Example 2:Input: root = [1,null,2]Output: 2 Constraints:The number of nodes in the tre..

Coding_Practice 2024.11.28

Generate Parentheses[String,Dynamic Programming,Backtracking]

https://leetcode.com/problems/generate-parentheses/description/Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1:Input: n = 3Output: ["((()))","(()())","(())()","()(())","()()()"]Example 2:Input: n = 1Output: ["()"] Constraints:1 간단한 Dynamic Programming 코딩 한 번 해보기!문제는 쉬워 보이나, 막상 코딩하려니까 좀 짜친다.  1. Python아래까지 풀다가 GG. 뭔가 뒤에 방법이 생각 안 난다..

Coding_Practice 2024.11.14

Find if Path Exists in Graph[Depth-First Search,Breadth-First Search,Union Find,Graph]

https://leetcode.com/problems/find-if-path-exists-in-graph/description/?envType=problem-list-v2&envId=graphThere is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is c..

Coding_Practice 2024.10.28

Deque 자료구조 만들어보기

https://leetcode.com/problems/design-circular-deque/사실 예전에 풀었던 문제인데, 다행히(?) 인간은 망각의 동물인지라 초면 인 것 마냥 풀었다. deque 구조의 delete / insert 등등의 method를 한번 구현해 보는 것이 골자! Design your implementation of the circular double-ended queue (deque).Implement the MyCircularDeque class:MyCircularDeque(int k) Initializes the deque with a maximum size of k.boolean insertFront() Adds an item at the front of Deque. Retu..

Coding_Practice 2024.10.27

Count Complete Tree Nodes[Binary Search,Bit Manipulation,Tree,Binary Tree]

https://leetcode.com/problems/count-complete-tree-nodes/description/Given the root of a complete binary tree, return the number of the nodes in the tree.According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.Design a..

Coding_Practice 2024.09.26

Sum of Prefix Scores of Strings[Array,String,Trie,Counting]

https://leetcode.com/problems/sum-of-prefix-scores-of-strings/description/?envType=daily-question&envId=2024-09-25You are given an array words of size n consisting of non-empty strings.We define the score of a string word as the number of strings words[i] such that word is a prefix of words[i].For example, if words = ["a", "ab", "abc", "cab"], then the score of "ab" is 2, since "ab" is a prefix ..

Coding_Practice 2024.09.25

Extra Characters in a String[Array,Hash Table,String,Dynamic Programming,Trie]

https://leetcode.com/problems/extra-characters-in-a-string/description/?envType=daily-question&envId=2024-09-23You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substring is present in dictionary. There may be some extra characters in s which are not present in any of the substrings.Return the m..

Coding_Practice 2024.09.23

Count the Number of Consistent Strings[E,Array,Hash Table,String,Bit Manipulation,Counting]

https://leetcode.com/problems/count-the-number-of-consistent-strings/description/?envType=daily-question&envId=2024-09-12You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed.Return the number of consistent strings in the array words. Example 1:Input: allowed = "ab", word..

Coding_Practice 2024.09.12

Count the Number of Good Subarrays[M,Array,Hash Table,Sliding Window]

https://leetcode.com/problems/count-the-number-of-good-subarrays/description/Given an integer array nums and an integer k, return the number of good subarrays of nums.A subarray arr is good if it there are at least k pairs of indices (i, j) such that i  and arr[i] == arr[j].A subarray is a contiguous non-empty sequence of elements within an array. Example 1:Input: nums = [1,1,1,1,1], k = 10Outpu..

Coding_Practice 2024.09.11

Insert Greatest Common Divisors in Linked List[M,Linked List,Math,Number Theory]

https://leetcode.com/problems/insert-greatest-common-divisors-in-linked-list/description/?envType=daily-question&envId=2024-09-10Given the head of a linked list head, in which each node contains an integer value.Between every pair of adjacent nodes, insert a new node with a value equal to the greatest common divisor of them.Return the linked list after insertion.The greatest common divisor of tw..

Coding_Practice 2024.09.10