CT47269

Uday and the Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the frontier camp of Duskwood with crates of ledgers, and Uday the valuer must account for every last one. Task: For each element print the value of the nearest element to its right that is strictly greater, or -1. Input format: First line: n. Second line: n integers. Output format: Print n answers space-separated. Constraints: 1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 63 317844432 -81008868 -176563056 964148437 452860490 -835317126 -694933866 -167735346 -957378687 241245178 -267832071 -598545263 -571483654 -534877809 -663250981 495467017 -749081527 -402194967 615337884 125042276 -4387537 -74313619 540094103 497667607 393749809 -301050527 838285064 831241791 -828153918 -474045569 300288955 -20789239 -336599435 492630518 903345588 191558053 -649526297 -819183817 -506380090 -892026734 -526294738 -313939524 -971967409 -412830621 -852441569 846704400 657818204 -457701341 -248434334 -648351875 -704210574 -571720461 -310727946 -597936953 -418308308 -286279713 614191556 679883959 -980283485 15506066 -682409126 -158263279 -973122405
Output: 964148437 964148437 964148437 -1 495467017 -694933866 -167735346 241245178 241245178 495467017 495467017 -571483654 -534877809 495467017 495467017 615337884 -402194967 615337884 838285064 540094103 540094103 540094103 838285064 838285064 838285064 838285064 903345588 903345588 -474045569 300288955 492630518 492630518 492630518 903345588 -1 846704400 -506380090 -506380090 -313939524 -526294738 -313939524 846704400 -412830621 846704400 846704400 -1 679883959 -248434334 614191556 -571720461 -571720461 -310727946 -286279713 -418308308 -286279713 614191556 679883959 -1 15506066 -1 -158263279 -1 -1

Example 2:

Input: 270 22066814 -853276852 -413333017 600720880 434288231 188881072 20131259 884411974 752350240 552250569 629151095 618290204 -76552076 -855106674 639368263 -490139700 -599540125 -308188477 536065472 -198744411 795835801 810894059 -628200623 -774399002 273376178 993219053 291459428 675467271 586314132 431754062 122285281 218420733 -659603143 -706091767 342332149 -140694018 -24362484 -973023523 779117559 -548229687 -600327573 814915985 611200948 -346938533 -344499922 -623938649 994312706 -385853337 -746940763 -816816776 -996676486 -398421146 -962137084 -86778339 -998555232 -344813048 -466371235 770101061 958211417 -228283895 810715586 848976683 794441271 529130879 312210712 188150357 228379753 -374037780 187030999 734897969 641979996 776017823 -343366702 -467769483 -127096293 763592602 601837…
Output: 600720880 -413333017 600720880 884411974 884411974 884411974 884411974 993219053 795835801 629151095 639368263 639368263 639368263 639368263 795835801 -308188477 -308188477 536065472 795835801 795835801 810894059 993219053 273376178 273376178 993219053 994312706 675467271 779117559 779117559 779117559 218420733 342332149 342332149 342332149 779117559 -24362484 779117559 779117559 814915985 814915985 814915985 994312706 994312706 -344499922 994312706 994312706 996832419 -86778339 -398421146 -398421146 -398421146 -86778339 -86778339 770101061 -344813048 770101061 770101061 958211417 976528343 810715586 848976683 976528343 976528343 734897969 734897969 228379753 734897969 187030999 734897969 776017823 776017823 976528343 -127096293 -127096293 763592602 976528343 701017881 701017881 701017881 …

Example 3:

Input: 3193 -302047321 265924701 -42301115 175986756 -566019946 162662235 476298587 433831246 -867034078 185718759 517733762 -345704193 -828556719 379976613 -21345087 -538726398 -65106408 152611622 750988719 18797159 769312219 -38533441 852924656 912985697 -1906654 -563194466 -331180070 470584878 785582707 933500405 636686009 -470075356 717796887 177982223 -556191814 -226043590 83972339 -743401273 121758879 783387074 -935253132 -313103250 661034013 262023296 207655676 -98335268 99904009 -973746214 -437610684 183124133 -324207841 228144480 75029240 200419184 579807179 -672076530 -180601156 316763390 94280148 82349945 -539162101 -916661093 -658247898 609135346 -609343193 682837565 -327053088 -551948915 562960546 -262877337 -327219302 827064005 827731456 -838106156 -746982102 -823317401 691528382 21…
Output: 265924701 476298587 175986756 476298587 162662235 476298587 517733762 517733762 185718759 517733762 750988719 379976613 379976613 750988719 152611622 -65106408 152611622 750988719 769312219 769312219 852924656 852924656 912985697 933500405 470584878 -331180070 470584878 785582707 933500405 939649708 717796887 717796887 783387074 783387074 -226043590 83972339 121758879 121758879 783387074 827064005 -313103250 661034013 682837565 579807179 228144480 99904009 183124133 -437610684 183124133 228144480 228144480 579807179 200419184 579807179 609135346 -180601156 316763390 609135346 609135346 609135346 609135346 -658247898 609135346 682837565 682837565 827064005 562960546 562960546 827064005 827064005 827064005 827731456 884856314 -746982102 691528382 691528382 823984929 502643268 502643268 -2418…

Constraints:

1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Loading...
Test Cases:No test cases
No test cases available.
Uday and the Taller Ahead - MEDIUM Coding Problem | CodeTikki