Merge Sorted Array Problem Description 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 nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be
Separate Black and White Balls Problem Description There are n balls on a table, each ball has a color black or white. You are given a 0-indexed binary string s of length n, where 1 and 0 represent black and white balls, respectively. In each step, you can choose two adjacent balls and swap them.
Reverse Prefix of Word Problem Description Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing. For example, if word = "abcdefd&
String Compression Problem Description Given an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating characters in chars: * If the group's length is 1, append the character to s. * Otherwise, append the character followed by the group&
Container with Most Water Problem Description You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains
Merge Two 2D Arrays by Summing Values Problem Statement You are given two 2D integer arrays nums1 and nums2. nums1[i] = [idᵢ, valᵢ] indicate that the number with the idᵢ has a value equal to valᵢ. nums2[i] = [idᵢ, valᵢ] indicate that the number with the idᵢ has a value equal to valᵢ. Each array contains unique
Minimum Length of String After Deleting Similar Ends Problem Description Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times: 1. Pick a non-empty prefix from the string s where all the characters in the
Merge Strings Alternately Problem Description You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string. Return the merged string. Examples Input: word1 = "abc&
Reverse String Problem Description You are required to write a function that reverses a string, where the input string is given as an array of characters s. Example Input: s = ["a","b","c","d","e"] Output: ["e","d"