Company: Rippling
Difficulty: easy
Sequential Promise Resolution A task queue holds n pending jobs, numbered 1 through n . Job i carries a single integer value promises[i - 1] . A job is settled by looking at its value: if the value is not 0 , the job resolves and produces that value; if the value is 0 , the job rejects . The jobs are settled one at a time, in the sequence given by the array order : first job order[0] , then job order[1] , and so on. Every value produced by a resolved job is appended to a result log, as a decimal string. The moment a job rejects, the whole run is aborted: the string Error Thrown is appended to the log and no further job is settled . Given promises and order , produce the result log. Input Format The first line contains an integer n , the number of elements in promises . Each of the next n lines contains an integer, promises[i] . The next line contains an integer n , the number of elements in order . Each of the next n lines contains an integer, order[i] . Output Format Print the entries