[LeetCode] 2054. Two Best Non-Overlapping Events (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a 0-indexed 2D integer array of events where events[i] = [startTime_i, endTime_i, value_i]. The ith event starts at startTime_i and ends at endTime_i, and if you attend this event, you will receive a value of value_i. You can choose at most two non-overlapping events to attend such that the sum of their values is maximized. Return this maximum sum. Note that the st..
[LeetCode] 2554. Maximum Number of Integers to Choose From a Range I (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명You are given an integer array banned and two integers n and maxSum. You are choosing some number of integers following the below rules:The chosen integers have to be in the range [1, n].Each integer can be chosen at most once.The chosen integers should not be in the array banned.The sum of the chosen integers should not exceed maxSum.Return the maximum number of integers you can..
[LeetCode] 2825. Make String a Subsequence Using Cyclic Increments (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given two 0-indexed strings str1 and str2.In an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to the next character cyclically. That is 'a' becomes 'b', 'b' becomes 'c', and so on, and 'z' becomes 'a'.Return true if it is possible to make str2 a subsequence of str1 by performing the operation at most once, and false ot..
[LeetCode] 2109. Adding Spaces to a String - Python
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index. For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain "En..
[LeetCode] 1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence - Python
·
알고리즘/LeetCode
난이도: Easy문제 설명Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.Return the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.A pr..
[LeetCode] 1346. Check If N and Its Double Exist - Python
·
알고리즘/LeetCode
난이도: Easy문제 설명Given an array arr of integers, check if there exist two indices i and j such that :i != j0 arr[i] == 2 * arr[j] 문제 예제Example 1:Input: arr = [10,2,5,3]Output: trueExplanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j] Example 2:Input: arr = [3,1,7,11]Output: falseExplanation: There is no i and j that satisfy the conditions. 제한 사항2 -10^3  ✏️ Solution(솔루션)class Solutio..