Four short array and string exercises
Four quick problems in one round:
- Return the difference between the number of uppercase and lowercase letters in a string.
- 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.
- Find the fewest unit increments that make an array either non-decreasing or non-increasing.
- Simulate a phone battery that charges and drains in cycles and answer the question about its charge.
No answer yet. Write the first one; the best answer gets endorsed.
