CT43523

Dora's beacons Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the opal reefs of Shimmerdeep opens only for a perfect tally of beacons. Dora means to find out. 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: 3435 929261027 842610679 -398666645 811189158 -151088989 -266065890 973732668 601122038 -910123250 827370516 -1119342 928633212 -943622200 439137348 -995802831 969442222 994639096 -311057642 286208832 469329313 634744548 -479040392 510679319 993716388 -167980510 -344045028 533443389 -227801317 556626887 -539381527 -215055650 41955704 -677886061 -836476990 -663990009 195605146 -322366536 233592824 -258239577 957998876 -13414806 715617998 -569839751 -425748993 310903720 159061322 -655459646 145913226 214291604 -292351142 -334468930 714719592 -273295112 443839843 -84162090 39473991 177516349 492912196 -458493522 768493895 788692108 458756990 -42675173 5964957 -672615324 -567948924 496839881 -68375461 -670712713 -471115126 -833389077 445391659 -372591216 -600822782 -500986364 804684763 7797303…
Output: 973732668 973732668 811189158 973732668 973732668 973732668 994639096 827370516 827370516 928633212 928633212 969442222 439137348 969442222 969442222 994639096 995503269 286208832 469329313 634744548 993716388 510679319 993716388 994510847 533443389 533443389 556626887 556626887 957998876 -215055650 41955704 195605146 -663990009 -663990009 195605146 233592824 233592824 957998876 957998876 967039521 715617998 768493895 -425748993 310903720 714719592 214291604 145913226 214291604 714719592 714719592 714719592 768493895 443839843 492912196 39473991 177516349 492912196 768493895 768493895 788692108 804684763 496839881 5964957 496839881 -567948924 496839881 804684763 445391659 -471115126 445391659 445391659 804684763 804684763 -500986364 804684763 822726842 800046320 764046174 764046174 -874804…

Example 2:

Input: 2734 -443014220 -599190655 -882613357 262731747 81668476 358486667 -97252420 289622651 893764219 801803693 -937594908 -242891663 202452025 292430260 25141408 157424624 995274398 -650270542 932725644 103547321 -669218493 -822219485 49673400 -102270462 799398546 -904686914 -58549784 -670144099 991701755 980104674 134108420 -668724570 825083466 874774836 -380476989 484899814 537042198 -777834782 -836049729 -125505408 917555826 46057019 523146431 -899972942 648334481 220091432 571257977 -580116816 -336642095 -962861492 134887417 679242810 59791773 -622146101 95763780 226227926 16845755 -371178262 -613722122 377735671 203423285 -542193805 665003555 -366851333 -82661645 -784816810 625603102 -551761052 -425666623 191142810 -280220745 673128299 739261257 -749368761 -337508488 946997521 311763004 2…
Output: 262731747 262731747 262731747 358486667 358486667 893764219 289622651 893764219 995274398 995274398 -242891663 202452025 292430260 995274398 157424624 995274398 999896456 932725644 991701755 799398546 49673400 49673400 799398546 799398546 991701755 -58549784 991701755 991701755 991817469 991817469 825083466 825083466 874774836 917555826 484899814 537042198 917555826 -125505408 -125505408 917555826 946997521 523146431 648334481 648334481 679242810 571257977 679242810 -336642095 134887417 134887417 679242810 739261257 95763780 95763780 226227926 377735671 377735671 377735671 377735671 665003555 665003555 665003555 673128299 -82661645 625603102 625603102 673128299 -425666623 191142810 673128299 673128299 739261257 946997521 -337508488 946997521 991817469 681390371 681390371 -96356435 -9635643…

Example 3:

Input: 339 -901162635 428507337 -318072776 -400241078 378390427 947971185 -700803560 -655531429 215704173 801383683 -253134448 -667138150 235150379 -471037378 -170705191 -150201047 -697660885 -211325860 415861671 998932837 488675132 933830015 -920408504 -480492153 -642844657 -519708816 457617815 496306305 562244776 -159898572 173390958 799768762 -25865961 152470619 -491484274 -824327399 -767334248 -946889777 -820732114 605331086 993546503 565600855 69512471 4743879 -936386608 -374093792 116611533 -865200260 357190880 734446787 -299657436 209595793 974391794 506548106 233728884 -579413297 -847746280 122687107 161024726 209662087 -597063261 127945665 492883291 533071048 -191617711 595756398 -609242575 514024689 551710472 -750344693 -404586700 907975762 -445991800 -342129674 -457827635 -319138862 -9…
Output: 428507337 947971185 378390427 378390427 947971185 998932837 -655531429 215704173 801383683 998932837 235150379 235150379 415861671 -170705191 -150201047 415861671 -211325860 415861671 998932837 -1 933830015 993546503 -480492153 457617815 -519708816 457617815 496306305 562244776 799768762 173390958 799768762 993546503 152470619 605331086 605331086 -767334248 605331086 -820732114 605331086 993546503 -1 734446787 116611533 116611533 -374093792 116611533 357190880 357190880 734446787 974391794 209595793 974391794 990371110 533071048 492883291 122687107 122687107 161024726 209662087 492883291 127945665 492883291 533071048 595756398 595756398 907975762 514024689 551710472 907975762 -404586700 907975762 960153069 -342129674 -319138862 -319138862 -97009785 137736425 546158561 673280430 673280430 4…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Dora's beacons Taller Ahead - MEDIUM Coding Problem | CodeTikki