CT54323

Farhan's Taller Ahead Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the savanna camp of Amberplain as Farhan unrolls the day's manifest of beacons. The tally will decide the next shipment. 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: 712 -62852309 -20293139 788815823 260743161 -26261374 218656318 -161915355 554185813 867001159 798417598 788424600 -170691677 531829647 -803398102 -14038804 554718622 -709314867 544248995 -804510834 -886645235 142884982 -308053453 95097306 -60848361 -657537988 124708758 164700983 331552384 -792554642 -278786146 337798000 -548923411 -786227353 643828621 988884204 -659792603 -467802465 466648564 391548617 -77690621 -370670434 -168479404 -212267064 -232126732 882153142 -247271747 -262711587 977886924 -895117004 111734523 -177634084 -552479613 -891263516 -448105504 -249686040 818628004 -957120806 737405416 619082565 715343002 210923426 -682047803 -316099698 -429392263 171885969 616936201 -493741681 -585198275 -921561330 97348877 148894110 -878722784 843470847 569857334 -3759715 249850724 57399…
Output: -20293139 788815823 867001159 554185813 218656318 554185813 554185813 867001159 988884204 988884204 988884204 531829647 554718622 -14038804 554718622 643828621 544248995 643828621 142884982 142884982 164700983 95097306 124708758 124708758 124708758 164700983 331552384 337798000 -278786146 337798000 643828621 643828621 643828621 988884204 993857444 -467802465 466648564 882153142 882153142 882153142 -168479404 882153142 882153142 882153142 977886924 977886924 977886924 981308550 111734523 818628004 818628004 -448105504 -448105504 -249686040 818628004 843470847 737405416 843470847 715343002 843470847 616936201 -316099698 171885969 171885969 616936201 843470847 97348877 97348877 97348877 148894110 843470847 843470847 914898051 573997801 249850724 573997801 754778305 754778305 810441618 8104416…

Example 2:

Input: 3532 621110122 -73777059 480777925 647413141 -692217013 -995291769 564496006 -202009891 442357323 839733003 204050824 -485526994 -605913845 -675922803 -175772644 -950190728 -629601375 -337253551 -199028917 186866763 803122167 -131238013 -577092726 3149733 625607153 -494264864 818122958 -468670184 -65738219 640300836 952790095 -143452983 -707840993 -897305608 687402086 235130270 91243888 158120444 -407658670 767664199 876717226 126029873 -303425970 -743797440 -870494609 392101436 412138178 -880663832 610913857 930053321 -582204654 -447629750 -340297972 717286371 664623365 559345036 -488004522 -412546880 -619540375 797243920 -685901988 -446668073 -317482418 86508686 654283029 973237074 -404461242 634659021 -425679933 553254922 -28122150 -566672861 -120634719 -336178323 -419295383 470806692 -…
Output: 647413141 480777925 647413141 839733003 564496006 564496006 839733003 442357323 839733003 952790095 803122167 -175772644 -175772644 -175772644 186866763 -629601375 -337253551 -199028917 186866763 803122167 818122958 3149733 3149733 625607153 818122958 818122958 952790095 -65738219 640300836 952790095 973237074 687402086 687402086 687402086 767664199 767664199 158120444 767664199 767664199 876717226 930053321 392101436 392101436 392101436 392101436 412138178 610913857 610913857 930053321 973237074 -447629750 -340297972 717286371 797243920 797243920 797243920 -412546880 797243920 797243920 973237074 -446668073 -317482418 86508686 654283029 973237074 981274677 634659021 727825448 553254922 727825448 470806692 -120634719 470806692 470806692 470806692 727825448 238497442 727825448 859629131 -36…

Example 3:

Input: 1071 636995362 -342030200 -236921799 666523312 -504714435 -866763915 216710905 995381435 -999476348 -107558890 621785030 -438193368 81130881 350271557 121904004 -271644454 -409068122 617754633 -660014378 -418968238 575309364 -842943726 874111075 337156002 463446520 851394793 -155174056 -572855774 -31990563 -673188978 -944616448 819506109 -531127343 -378275441 601212992 -575468810 501787628 -88879396 656856618 447968127 -116833916 272402272 -967371600 -389017184 23503577 -136483719 -829189582 38743436 -16460452 -306116985 -619070061 164163218 -417723357 212798632 -746132543 206142735 894101521 836274072 -457651700 -451257787 45319402 199142102 -151102952 181471383 761791336 -147175132 -790072336 -281674855 63591146 748693200 -713062567 -34225752 -349573050 682829458 -188205677 -543172290 11…
Output: 666523312 -236921799 666523312 995381435 216710905 216710905 995381435 996726751 -107558890 621785030 874111075 81130881 350271557 617754633 617754633 617754633 617754633 874111075 -418968238 575309364 874111075 874111075 894101521 463446520 851394793 894101521 -31990563 -31990563 819506109 819506109 819506109 894101521 -378275441 601212992 656856618 501787628 656856618 656856618 894101521 894101521 272402272 894101521 -389017184 23503577 38743436 38743436 38743436 164163218 164163218 164163218 164163218 212798632 212798632 894101521 206142735 894101521 954241694 954241694 -451257787 45319402 199142102 761791336 181471383 761791336 793905714 63591146 -281674855 63591146 748693200 793905714 -34225752 682829458 682829458 685834824 119573794 119573794 474992003 -480926563 -364775524 474992003…

Constraints:

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

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