[LeetCode] 1790. Check if One String Swap Can Make Strings Equal (Python)
·
알고리즘/LeetCode
난이도: Easy문제 설명You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices. Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings. Otherwise, return false. 문제 예제Example 1:Input: s1 = "bank", s2 =..
[LeetCode] 1800. Maximum Ascending Subarray Sum (Python)
·
카테고리 없음
난이도: Easy문제 설명Given an array of positive integers nums, return the maximum possible sum of an ascending subarray in nums. A subarray is defined as a contiguous sequence of numbers in an array. A subarray [numsl, numsl+1, ..., numsr-1, numsr] is ascending if for all i where l , numsi i+1. Note that a subarray of size 1 is ascending. 문제 예제Example 1:Input: nums = [10,20,30,5,10,50]Output: 65Explan..
[LeetCode] 3105. Longest Strictly Increasing or Strictly Decreasing Subarray (Python)
·
알고리즘/LeetCode
난이도: Easy문제 설명You are given an array of integers nums. Return the length of the longest subarray of nums which is either strictly increasing or strictly decreasing. 문제 예제Example 1:Input: nums = [1,4,3,3,2]Output: 2Explanation:The strictly increasing subarrays of nums are [1], [2], [3], [3], [4], and [1,4].The strictly decreasing subarrays of nums are [1], [2], [3], [3], [4], [3,2], and [4,3].Hen..
[LeetCode] 1752. Check if Array Is Sorted and Rotated (Python)
·
알고리즘/LeetCode
난이도: Easy문제 설명Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise, return false. There may be duplicates in the original array. Note: An array A rotated by x positions results in an array B of the same length such that A[i] == B[(i+x) % A.length], where % is the modulo operation. 문제 예제Examp..
[LeetCode] 3151. Special Array I (Python)
·
알고리즘/LeetCode
난이도: Easy문제 설명An array is considered special if every pair of its adjacent elements contains two numbers with different parity. You are given an array of integers nums. Return true if nums is a special array, otherwise, return false. 문제 예제Example 1:Input: nums = [1]Output: trueExplanation:There is only one element. So the answer is true.Example 2:Input: nums = [2,1,4]Output: trueExplanation:Ther..
[LeetCode] 827. Making A Large Island (Python)
·
알고리즘/LeetCode
난이도: Hard문제 설명You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4-directionally connected group of 1s. 문제 예제Example 1:Input: grid = [[1,0],[0,1]] Output: 3 Explanation: Change one 0 to 1 and connect two 1s, then we get an island with area = 3. Example 2:Input: gri..