Eat Study Love

먹고 공부하고 사랑하라

Python 159

Longest Nice Substring[Hash Table,String,Divide and Conquer,Bit Manipulation,Sliding Window]

https://leetcode.com/problems/longest-nice-substring/description/A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, "abA" is not because 'b' appears, but 'B' does not.Given a string s, return the longest substring of s that is nice. If there ..

Coding_Practice 2024.10.10

Sort List[Linked List,Two Pointers,Divide and Conquer,Sorting,Merge Sort]

https://leetcode.com/problems/sort-list/description/Given the head of a linked list, return the list after sorting it in ascending order. Example 1:Input: head = [4,2,1,3]Output: [1,2,3,4]Example 2:Input: head = [-1,5,3,4,0]Output: [-1,0,3,4,5]Example 3:Input: head = []Output: [] Constraints:The number of nodes in the list is in the range [0, 5 * 104].-105  Follow up: Can you sort the linked lis..

Coding_Practice 2024.10.10

Majority Element[Array,Hash Table,Divide and Conquer,Sorting,Counting]

https://leetcode.com/problems/majority-element/description/Given an array nums of size n, return the majority element.The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1:Input: nums = [3,2,3]Output: 3Example 2:Input: nums = [2,2,1,1,1,2,2]Output: 2 Constraints:n == nums.length1 -109  Follow-up: C..

Coding_Practice 2024.10.10

Minimum Add to Make Parentheses Valid[M,String,Stack,Greedy]

https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/description/?envType=daily-question&envId=2024-10-09A parentheses string is valid if and only if:It is the empty string,It can be written as AB (A concatenated with B), where A and B are valid strings, orIt can be written as (A), where A is a valid string.You are given a parentheses string s. In one move, you can insert a parent..

Coding_Practice 2024.10.09

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