[Leetcode] 724 Find Pivot Index (Python)
leetcode2025. 9. 29. 17:16[Leetcode] 724 Find Pivot Index (Python)

문제Find Pivot Index - LeetCode설명Given an array of integers nums, calculate the pivot index of this array.The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right.If the index is on the left edge of the array, then the left sum is 0 because there are no elements to the left. This also applie..

[Leetcode] 2390 Removing Starts From a String (Python)
leetcode2025. 9. 24. 13:11[Leetcode] 2390 Removing Starts From a String (Python)

문제Removing Stars From a String - LeetCode설명You are given a string s, which contains stars *.In one operation, you can:Choose a star in s.Remove the closest non-star character to its left, as well as remove the star itself.Return the string after all stars have been removed.Note:The input will be generated such that the operation is always possible.It can be shown that the resulting string will a..

[Leetcode] 151 Reverse Words in a String (Python)
leetcode2025. 9. 23. 22:37[Leetcode] 151 Reverse Words in a String (Python)

문제Reverse Words in a String - LeetCode설명Given an input string s, reverse the order of the words.A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space.Return a string of the words in reverse order concatenated by a single space.Note that s may contain leading or trailing spaces or multiple spaces between two words. The returned string shou..

[Leetcode] 1732 Find the Highest Altitude (Python)
leetcode2025. 9. 22. 22:00[Leetcode] 1732 Find the Highest Altitude (Python)

문제Find the Highest Altitude - LeetCode설명There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0.You are given an integer array gain of length n where gain[i] is the net gain in altitude between points i and i + 1 for all (0 . Return the highest altitude of a point.풀이 계획변수 init을 0으로 잡고 gain을 돌..

[Leetcode] 1456 Maximum Number of Vowels in a Substring of Given Length (Python)
leetcode2025. 9. 17. 14:42[Leetcode] 1456 Maximum Number of Vowels in a Substring of Given Length (Python)

문제Maximum Number of Vowels in a Substring of Given Length - LeetCode설명Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.풀이 계획가장 많은 모음이 포함된 k의 길이만큼의 문자열에서의 모음의 갯수를 구하는 문제이다.초기 풀이 (8384ms, 18.22MB)class Solution: def maxVowels(self, s: str, k: int) -> int: vowels="aeio..

[Leetcode] 392 Is Subsequence (Python)
leetcode2025. 9. 16. 21:52[Leetcode] 392 Is Subsequence (Python)

문제Is Subsequence - LeetCode설명Given two strings s and t, return true if s is a subsequence of t, or false otherwise.A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).풀이 계획초기값으로 0을 갖는 변수 ..

[Leetcode] 2348 Number of Zero-Filled Subarrays (Python)
leetcode2025. 8. 20. 00:35[Leetcode] 2348 Number of Zero-Filled Subarrays (Python)

Number of Zero-Filled Subarrays - LeetCode생각리스트를 한번 돌면서 0이 이어진다면 몇번까지 이어지는지 확인하고 이어지는 그룹이 몇개인지도 파악한다.몇번까지 이어지는지만 알면 subarrays 개수는 구할 수 있다.그때그때 0이 이어지는 상태인지 확인이 필요하다.삼각수 배열을 미리 뽑아놓고 갖다 쓰면 좋지 않을까?초기코드class Solution: def zeroFilledSubarray(self, nums: List[int]) -> int: limit = 10**5 triangular_numbers = [n * (n + 1) // 2 for n in range(1, limit + 1)] arr = [] streakF..

728x90
반응형
image