Palindrome After Deleting One Character
Determine if a string can be a palindrome after deleting at most one character.
Input: s = "abc"
Output: FALSE
Explanation: Deleting any single character leaves either "ab", "bc", or "ac", none of which result in a valid palindrome.
Implement the next permutation algorithm.
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such an arrangement is not possible, it must rearrange it as the lowest possible order.
Input: nums = [3,2,1]
Output: [1,2,3]
Explanation: The sequence is strictly decreasing…
Calculate how much rainwater can be trapped between elevation bars.
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Input: height = [4,2,0,3,2,5]
Output: 9
Explanation: Water is trapped between the boundaries of 4 and 5. The trapped volumes…
Maximum Subarray Sum
Find the maximum subarray sum in an integer array.
Input: nums = [-3,-4,-1,-2]
Output: -1
Explanation: Kadane's algorithm correctly identifies that the single isolated element -1 provides the highest possible sum.