Loading [MathJax]/jax/output/CommonHTML/jax.js
We will find a way, we always have.

-interstellar

Problem Solving/리트코드 6

[LeetCode] 2516. Take K of Each Character From Left and Right

🔈 문제You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost character of s, or the rightmost character of s.Return the minimum number of minutes needed for you to take at least k of each character, or return -1 if it is not possible to take k of each character. 💫 예시Input: s = "aabaaaacaabc", k = 2..

[LeetCode] 2563. Count the Number of Fair Pairs

🔈 문제Given a 0-indexed integer array nums of size n and two integers lower and upper, return the number of fair pairs.A pair (i, j) is fair if:0  💫 예시Input: nums = [0,1,7,4,4,5], lower = 3, upper = 6 Output: 6 Explanation: There are 6 fair pairs: (0,3), (0,4), (0,5), (1,3), (1,4), and (1,5). 🎱 제한1 nums.length == n109 109  📚 문제 풀이 문제를 요약하자면 nums에서 i, j 를 골라(i != j)  더했을 때 lower 보다 같거나 ..

[LeetCode] 3036. Number of Subarrays That Match a Pattern II

🔈 문제 You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1. A subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]: nums[i + k + 1] > nums[i + k] if pattern[k] == 1. nums[i + k + 1] == nums[i + k] if pattern[k] == 0. nums[i + k + 1] < nums[i..

[LeetCode] 1657. Determine if Two Strings Are Close

🔈 문제 Two strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters.For example, abcde -> aecdb Operation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character. For example, aacabb -> bbcbaa (all a's turn into b's, and all b's turn into ..

1