CT54110

Verdant ledgers Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Tanya the valuer watches over the temple city of Sunspire's stores of ledgers. A careful computation stands between order and chaos. 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: 738 -605404556 -545296157 264989188 -620838059 143710439 -741107900 -428541895 -753635865 181232916 -158665772 586805191 391432485 124799354 -173628579 -522918272 -957040041 718179984 879109408 -801800892 675740553 -940812654 -106596180 -913630694 -798578313 -496197713 593547861 212696117 -496168074 -736076604 823296010 -3979683 684620084 -774182286 -882249657 946471269 358162791 -563075047 751832009 -337600190 -915934152 -436401176 -385351544 231006258 325330163 747475270 344385223 -652737254 400387937 817158526 517196183 857078817 -619421347 -25078342 -729641985 315450006 -473632313 433882737 608056541 -40444600 -834092373 -862121592 -271864028 149766480 -967213068 78844155 547241804 -511650848 647934299 -827106303 947775816 676294449 824887387 375241284 -999079735 211496631 -904026103 -…
Output: -545296157 264989188 586805191 143710439 181232916 -428541895 181232916 181232916 586805191 586805191 718179984 718179984 718179984 718179984 718179984 718179984 879109408 946471269 675740553 823296010 -106596180 593547861 -798578313 -496197713 593547861 823296010 823296010 823296010 823296010 946471269 684620084 946471269 946471269 946471269 947775816 751832009 751832009 817158526 231006258 -436401176 -385351544 231006258 325330163 747475270 817158526 400387937 400387937 817158526 857078817 857078817 947775816 -25078342 315450006 315450006 433882737 433882737 608056541 647934299 149766480 -271864028 -271864028 149766480 547241804 78844155 547241804 647934299 647934299 947775816 947775816 973472447 824887387 921178301 921178301 211496631 268958934 -545694151 268958934 268958934 921178301 9…

Example 2:

Input: 19 -900483053 -100236758 298092031 965806473 762681760 195889859 -537881855 -323315541 664525362 379918939 -509473875 975902571 -219551731 664406664 743267868 -643544851 -454841751 -779414144 729940438
Output: -100236758 298092031 965806473 975902571 975902571 664525362 -323315541 664525362 975902571 975902571 975902571 -1 664406664 743267868 -1 -454841751 729940438 729940438 -1

Example 3:

Input: 951 -140121313 807864164 -851806538 -328519563 271751016 348044293 371158656 -444896368 -264827081 242474907 526059276 -773541407 -19063064 -7169066 -756608982 204420133 -470663518 -47230054 -236767644 244597225 610402233 908279758 355935314 -264380646 437430731 -167316706 -841282107 83660380 -766322088 -64990336 266796441 541802171 111027618 12599787 -871420957 416265989 199210393 500994542 500612844 -919717921 -830188239 -901333828 -607300207 -141372976 24441241 124377584 -307544638 -51632720 483342558 693729407 -559255123 -256430350 -940175908 -870970329 425038766 23466620 -944146357 881688412 -544024945 -975963608 810142169 -753942304 -530394432 -900825404 621394802 378319455 -4633982 226930331 436535420 -774526921 -50037999 689049856 -744489665 817845666 81396535 -864092470 573041176 …
Output: 807864164 908279758 -328519563 271751016 348044293 371158656 526059276 -264827081 242474907 526059276 610402233 -19063064 -7169066 204420133 204420133 244597225 -47230054 244597225 244597225 610402233 908279758 973591376 437430731 437430731 541802171 83660380 83660380 266796441 -64990336 266796441 541802171 693729407 416265989 416265989 416265989 500994542 500994542 693729407 693729407 -830188239 -607300207 -607300207 -141372976 24441241 124377584 483342558 -51632720 483342558 693729407 881688412 -256430350 425038766 -870970329 425038766 881688412 881688412 881688412 894297010 810142169 810142169 817845666 -530394432 621394802 621394802 689049856 436535420 226930331 436535420 689049856 -50037999 689049856 817845666 817845666 839798482 573041176 573041176 839798482 894297010 643370624 75087…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Verdant ledgers Taller Ahead - MEDIUM Coding Problem | CodeTikki