Please read the important note at the bottom of the page.
Question
Reverse all the words in a string of words and spaces/tabs while preserving the word order and spacing.
Example
'moo cow bark dog' -> 'oom woc krab god'Potential pitfalls:
Don't reverse the entire string -- preserve the word ordering and the spaces. We make no guarantee about how many spaces/tabs there are between words, so you can't split (using the .split() method) and then reverse the words individually.

Question
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays.
Example 1:
nums1 = [1, 3]
nums2 = [2]
The median is 2.0Example 2:
nums1 = [1, 2]
nums2 = [3, 4]
The median is (2 + 3)/2 = 2.5Simple as you like them to be!
Last Question
A subarray of an array is a consecutive sequence of zero or more values taken
out of that array. For example, the array [1, 3, 7] has seven subarrays:
[ ] [1] [3] [7] [1, 3] [3, 7] [1, 3, 7]Notice that [1, 7] is not a subarray of [1, 3, 7], because even though the values 1 and 7 appear in the array, they're not consecutive in the array. Similarly, the array [7, 3] isn't a subarray of the original array, because these values are in the wrong order.
The sum of an array is the sum of all the values in that array. Your task is to write a function that takes as input an array and outputs the sum of all of its subarrays.
For example, given [1, 3, 7], you'd output 36, because:
[ ] + [1] + [3] + [7] + [1, 3] + [3, 7] + [1, 3, 7]
= 0 + 1 + 3 + 7 + 4 + 10 + 11 = 36Hints for this question:
subarray_sum_slow: the easy but slow way to do it. Just enumerate all the
subarrays and sum them up.
subarray_sum: the fast way to do it. We can calculate the number of times
each element occurs and sum them up.
Note:
All test cases except for the listed examples for questions are not going to be continued anymore on the site. Submissions are still going to take the same trend but your code is going to be scored according to the number of test cases it passes -- as you see on coding sites nowadays!