Next Stronger Signal
easyA radio tower logs signal strengths over a session as readings — a list of distinct integers. Engineers care about a few of those readings, listed in watch (every value in watch appears somewhere in readings).
For each value in watch, report the first reading to its right in readings that is strictly stronger. If no later reading is stronger, report -1. Return the answers in the same order as watch.
Example 1
in watch = [4, 1, 2], readings = [1, 3, 4, 2]
out [-1, 3, -1]
After 4 nothing is stronger; after 1 the next stronger is 3; after 2 (the last reading) nothing follows.
Example 2
in watch = [2, 4], readings = [1, 2, 3, 4]
out [3, -1]
Constraints
- · 1 <= len(watch) <= len(readings) <= 10^4
- · all values are distinct integers in [-10^9, 10^9]
- · every value of watch appears in readings
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.