CT53425

Hans and the Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Hans inherited the ropewalk at the rookery of Crowhaven along with its curious bookkeeping system for marks. Time to make sense of it. 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: 543 -104072092 -639725949 -188103786 260670832 -339217034 -174027711 789457504 -23263825 636409152 -521674410 743508155 433212035 -273683562 -701331224 -824799931 995879569 -759123667 -880140619 -164644076 -509678177 -964610601 462338806 616691912 -78761605 302280032 -927525067 993839016 -741484306 767349344 -304044987 56527227 -143929942 815943269 -832071112 -45195723 94799039 -156711150 234608488 -993539523 565284470 506259860 829592356 -31666847 -692043766 883665579 728460350 -218333795 515818137 -237529823 569033211 -47563609 415376002 806405380 568547889 -800967071 -320360789 161303173 -286947925 -555846041 972187305 687990605 -503235000 -584044626 321038171 -795363286 -357265597 262028376 -984019149 -408259351 -321866797 112943907 880680524 817817659 345767557 435546875 -661466690 46…
Output: 260670832 -188103786 260670832 789457504 -174027711 789457504 995879569 636409152 743508155 743508155 995879569 995879569 995879569 995879569 995879569 997132750 -164644076 -164644076 462338806 462338806 462338806 616691912 993839016 302280032 993839016 993839016 995480939 767349344 815943269 56527227 815943269 815943269 829592356 -45195723 94799039 234608488 234608488 565284470 565284470 829592356 829592356 883665579 883665579 883665579 972187305 806405380 515818137 569033211 569033211 806405380 415376002 806405380 972187305 972187305 -320360789 161303173 972187305 972187305 972187305 988666524 880680524 321038171 321038171 880680524 -357265597 262028376 880680524 -408259351 -321866797 112943907 880680524 988666524 850002370 435546875 466130714 466130714 519327042 584977738 584977738 7485…

Example 2:

Input: 1511 -668477080 845325138 -529947691 222116193 -887895968 -315754800 790045771 -6751187 152704856 349967802 -147560869 -931290752 333068032 -911994748 -6028050 874141972 807587382 348225142 -531689893 148954325 163668088 259423816 -936236190 805755221 -487780608 3944096 182390218 -795772925 -301928719 305851589 797091829 573506446 -177458692 -396198491 310620329 -2555852 -751431012 29784940 277266477 -803304395 177753488 -358492668 32454350 -154444495 765935235 -569793606 -993313461 104592079 193867152 235529486 -844586533 172936416 -457311854 868247488 -758691541 -228658948 -477832195 971670945 -766384992 -719625859 -585522292 -683320458 537091834 -143327577 -340579880 757190293 65110624 5780523 206697220 -136479962 -788409852 571815343 -411149523 360433006 827287684 -172431098 538475129 …
Output: 845325138 874141972 222116193 790045771 -315754800 790045771 874141972 152704856 349967802 874141972 333068032 333068032 874141972 -6028050 874141972 971670945 868247488 805755221 148954325 163668088 259423816 805755221 805755221 868247488 3944096 182390218 305851589 -301928719 305851589 797091829 868247488 765935235 310620329 310620329 765935235 29784940 29784940 277266477 765935235 177753488 765935235 32454350 765935235 765935235 868247488 104592079 104592079 193867152 235529486 868247488 172936416 868247488 868247488 971670945 -228658948 971670945 971670945 993534359 -719625859 -585522292 537091834 537091834 757190293 757190293 757190293 827287684 206697220 206697220 571815343 571815343 571815343 827287684 360433006 827287684 949721064 538475129 713790603 277265471 713790603 949721064 9…

Example 3:

Input: 49 -260040403 -935392619 -297208672 -146041331 819696482 -717213293 173691266 668172787 282939585 -631066240 457718917 612695912 920715519 -688910355 -86907650 -786793828 435629766 14118664 -566506188 -773924804 -549917174 513786773 -373688950 100824303 893014715 -916573560 80541707 221295928 200774485 -871653386 -843750518 973567468 -985818272 -226136317 229677414 51113400 651293736 429998430 -945108292 -345847676 -137645945 313476670 -249090846 -63062107 269125898 929136035 648201904 724184318 285786829
Output: -146041331 -297208672 -146041331 819696482 920715519 173691266 668172787 920715519 457718917 457718917 612695912 920715519 973567468 -86907650 435629766 435629766 513786773 513786773 -549917174 -549917174 513786773 893014715 100824303 893014715 973567468 80541707 221295928 973567468 973567468 -843750518 973567468 -1 -226136317 229677414 651293736 651293736 929136035 929136035 -345847676 -137645945 313476670 929136035 -63062107 269125898 929136035 -1 724184318 -1 -1

Constraints:

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

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