Merge two sorted arrays into one sorted array.
You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge them into a single array sorted in non-decreasing order.
Input: nums1 = [0], m = 0, nums2 = [1], n = 1
Outp…
Two Sum
You're presented with an array of integers and a specific target value. Your task is to identify and return the indices of two numbers from the array that add up to the target. You can assume there's exactly one solution, and you can't use the same element twice. The indices can be returned in any order.
Input: nums = [14,8,22,6…
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…