Multiple providers of the same context nest; the innermost wins per subtree. Input: a JSON array of {"depth": number, "value": string} providers on the path to a consumer (depth ascending). Print the value the consumer reads (or default if the array is empty).
Input: one JSON array. Output: the winning value.
Your program reads from stdin and prints to stdout.
Example 1
Input: [{"depth":1,"value":"red"},{"depth":3,"value":"blue"}]
Output: blue
Hints
Multiple providers of the same context nest; the innermost wins per subtree. Input: a JSON array of {"depth": number, "value": string} providers on the path to a consumer (depth ascending). Print the value the consumer reads (or default if the array is empty).
Input: one JSON array. Output: the winning value.
Your program reads from stdin and prints to stdout.
Example 1
Input: [{"depth":1,"value":"red"},{"depth":3,"value":"blue"}]
Output: blue
Hints