Four short array and string exercises

0
Remix

Four quick problems in one round:

  1. Return the difference between the number of uppercase and lowercase letters in a string.
  2. Repeatedly subtract from the non-zero elements of an array, scanning from the left, until every element is zero, stopping a pass when you reach a value strictly smaller than the current one; report what the problem asks for at the end.
  3. Find the fewest unit increments that make an array either non-decreasing or non-increasing.
  4. Simulate a phone battery that charges and drains in cycles and answer the question about its charge.
MetaCodingLast asked Dec 2025
No answer yet. Write the first one; the best answer gets endorsed.