[LeetCode] 1930. Unique Length-3 Palindromic Subsequences (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindrome is a string that reads the same forwards and backwards. A subsequence of a string is a new string generated from the original string with some characters (can b..
[LeetCode] 2270. Number of Ways to Split Array (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a 0-indexed integer array nums of length n.nums contains a valid split at index i if the following are true:The sum of the first i + 1 elements is greater than or equal to the sum of the last n - i - 1 elements.There is at least one element to the right of i. That is, 0 Return the number of valid splits in nums. 문제 예제Example 1:Input: nums = [10,4,-8,7]Output: 2Expl..
[LeetCode] 2559. Count Vowel Strings in Ranges (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a 0-indexed array of strings words and a 2D array of integers queries. Each query queries[i] = [l_i, r_i] asks us to find the number of strings present in the range li to ri (both inclusive) of words that start and end with a vowel. Return an array ans of size queries.length, where ans[i] is the answer to the ith query. Note that the vowel letters are 'a', 'e', 'i'..
[LeetCode] 1422. Maximum Score After Splitting a String (Python)
·
알고리즘/LeetCode
난이도: Easy 문제 설명Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring). The score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring. 문제 예제Example 1:Input: s = "011101"Output: 5 Explanation: All possible ways of splitting s into..
[LeetCode] 322. Coin Change (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.You may assume that you have an infinite number of each kind of coin. 문제 예제Example ..
[LeetCode] 983. Minimum Cost For Tickets (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array days. Each day is an integer from 1 to 365.Train tickets are sold in three different ways:a 1-day pass is sold for costs[0] dollars,a 7-day pass is sold for costs[1] dollars, anda 30-day pass is sold for costs[2] dollars.The passes allow that man..