Eat Study Love

먹고 공부하고 사랑하라

코딩테스트 61

Minimum String Length After Removing Substrings[E,StringStackSimulation]

https://leetcode.com/problems/minimum-string-length-after-removing-substrings/description/?envType=daily-question&envId=2024-10-07You are given a string s consisting only of uppercase English letters.You can apply some operations to this string where, in one operation, you can remove any occurrence of one of the substrings "AB" or "CD" from s.Return the minimum possible length of the resulting s..

Coding_Practice 2024.10.07

Find the Length of the Longest Common Prefix[M,Array,Hash Table,String,Trie]

https://leetcode.com/problems/find-the-length-of-the-longest-common-prefix/description/?envType=daily-question&envId=2024-09-24You are given two arrays with positive integers arr1 and arr2.A prefix of a positive integer is an integer formed by one or more of its digits, starting from its leftmost digit. For example, 123 is a prefix of the integer 12345, while 234 is not.A common prefix of two in..

Coding_Practice 2024.09.24

Palindrome Linked List[Linked List,Two Pointers,Stack,Recursion]

https://leetcode.com/problems/palindrome-linked-list/description/Given the head of a singly linked list, return true if it is a palindrome or false otherwise. Example 1:Input: head = [1,2,2,1]Output: trueExample 2:Input: head = [1,2]Output: false Constraints:The number of nodes in the list is in the range [1, 105].0  Follow up: Could you do it in O(n) time and O(1) space? 해당 문제를 Recursion / Data..

Coding_Practice 2024.09.23

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

Count Good Nodes in Binary Tree[Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/count-good-nodes-in-binary-tree/Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X.Return the number of good nodes in the binary tree. Example 1:Input: root = [3,1,4,3,null,1,5]Output: 4Explanation: Nodes in blue are good.Root Node (3) is always a good node.Node 4 -> (3,4) is the ..

Coding_Practice 2024.09.09

Number of Good Leaf Nodes Pairs[Tree,Depth-First Search,Binary Tree]

https://leetcode.com/problems/number-of-good-leaf-nodes-pairs/description/You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.Return the number of good leaf node pairs in the tree. Example 1:Input: root = [1,2,3,null,4], distance = ..

Coding_Practice 2024.09.09

Sum of Digits of String After Convert[E,String,Simulation]

https://leetcode.com/problems/sum-of-digits-of-string-after-convert/description/?envType=daily-question&envId=2024-09-03You are given a string s consisting of lowercase English letters, and an integer k.First, convert s into an integer by replacing each letter with its position in the alphabet (i.e., replace 'a' with 1, 'b' with 2, ..., 'z' with 26). Then, transform the integer by replacing it w..

Coding_Practice 2024.09.03