
You are given a sentence s consisting of words separated by single spaces.
Transform it into a new sentence using these rules:
a,e,i,o,u
or
A,E,I,O,U
), keep the word as-is.
"ma"
to the end of the word.
'a'
repeated
i
times, where
i
is the 1-based index of the word in the sentence.
Input: a string s
Output: the transformed string
You are given an integer array arr (may contain duplicates), e.g. [5, 2, 2, 4, 3].
You want to reorder the array into nondecreasing order.
Return the minimum total cost required to transform arr into sorted order.
Input: integer array arr
Output: minimum total moving distance (an integer)
Notes/constraints (typical interview scale):
O(n^2)
time for large
n
.