CT41522

Chetan's Granite Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the saffron fields of Marigold Row, Chetan records each signals in a worn leather ledger. The guild wants answers, not guesses. 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: 808 -565955236 -916261316 247535192 -17454308 26543449 438662496 189869836 985247548 985222159 75813002 751387486 124365635 813433362 576612855 -348224304 292687859 569113286 814124674 -853910892 -993769925 678758855 314643062 356769011 674869043 -947857068 734111922 968014855 -758975398 -193218445 -714539294 569252955 -26037466 -732661251 -319850863 411313745 -841893788 392463832 -737732305 491087656 859081696 82417610 -666248017 -926882722 69876865 -320531947 169437345 166098160 306316816 -891867480 -158692195 733628197 -756140899 -869645650 -805431165 -241519215 -127169606 612420218 99761636 -754320950 655493264 -551444291 -21680652 321272569 -281341927 940233954 817616585 -153645362 -717593875 63245081 -260964936 -975805495 -503335963 -966402916 876150842 -802141050 -695994880 -7829546…
Output: 247535192 247535192 438662496 26543449 438662496 985247548 985247548 998112704 998112704 751387486 813433362 813433362 814124674 814124674 292687859 569113286 814124674 968014855 678758855 678758855 734111922 356769011 674869043 734111922 734111922 968014855 998112704 -193218445 569252955 569252955 859081696 411313745 -319850863 411313745 491087656 392463832 491087656 491087656 859081696 940233954 169437345 69876865 69876865 169437345 169437345 306316816 306316816 733628197 -158692195 733628197 940233954 -241519215 -805431165 -241519215 -127169606 612420218 655493264 655493264 655493264 940233954 -21680652 321272569 940233954 940233954 948924008 876150842 63245081 63245081 876150842 876150842 -503335963 876150842 876150842 948924008 -695994880 529686845 529686845 646502236 948924008 634099…

Example 2:

Input: 3257 734449693 -214612257 -14380103 -92599771 -408495732 -948347811 638241280 -106883792 -821642290 708938047 -808493188 987713382 226819802 622147353 301590406 164893883 605959588 -978247629 -265635353 -520711266 -668633881 -358300912 509642561 843983602 661038323 727087887 -332471265 25718768 720315486 703358231 247898691 -212916022 188317026 -945357916 -594695782 -472991187 -3716784 -179647951 417926565 373487934 865215370 810588952 -880684762 338963847 -540900880 -687097807 -535306987 -761964117 958797637 -496827817 -20284270 -484497639 -400275513 -703604882 -513572011 164851344 -964215852 774429317 491409207 511396048 984807028 -846975219 -83873088 760833951 270499090 106097285 218382912 245983917 845325193 -625970230 678487601 201537741 -99492309 702843150 -198225637 614901683 -37035…
Output: 987713382 -14380103 638241280 638241280 638241280 638241280 708938047 708938047 708938047 987713382 987713382 992247867 622147353 843983602 605959588 605959588 843983602 -265635353 509642561 -358300912 -358300912 509642561 843983602 865215370 727087887 865215370 25718768 720315486 865215370 865215370 417926565 188317026 417926565 -594695782 -472991187 -3716784 417926565 417926565 865215370 865215370 958797637 958797637 338963847 958797637 -535306987 -535306987 958797637 958797637 984807028 -20284270 164851344 -400275513 164851344 -513572011 164851344 774429317 774429317 984807028 511396048 984807028 992247867 -83873088 760833951 845325193 845325193 218382912 245983917 845325193 872607878 678487601 702843150 702843150 702843150 872607878 614901683 872607878 -27998690 -27998690 123247273 872…

Example 3:

Input: 3003 -54668555 -788543846 425134291 955083578 415706056 -710855643 -14785628 418961513 -890752788 67142028 139231893 837452711 196854533 -612224223 -96259019 -229843709 639844219 715041118 -518213968 -699506468 452192751 507425162 646623505 709234614 -670420147 110662147 -827138985 722165666 816805704 727900312 622438965 625933041 858919730 854187314 -976960365 371115213 -32024705 967566653 -731753880 -597302833 385283350 -470451355 -529243487 -883769673 -133000019 -753807611 -802565548 768720001 -788986234 -114636644 -192705195 -130065262 175964339 618218908 -481130496 595683272 -712256638 -794946706 -59112982 -711135363 -470557486 407903716 978344573 -213251318 -513922298 -161719298 -77218969 744540226 462346881 -399167674 -351586774 -936659130 -896965567 406080468 -878108748 840698750 -…
Output: 425134291 425134291 955083578 967566653 418961513 -14785628 418961513 837452711 67142028 139231893 837452711 858919730 639844219 -96259019 639844219 639844219 715041118 722165666 452192751 452192751 507425162 646623505 709234614 722165666 110662147 722165666 722165666 816805704 858919730 858919730 625933041 858919730 967566653 967566653 371115213 967566653 967566653 978344573 -597302833 385283350 768720001 -133000019 -133000019 -133000019 768720001 768720001 768720001 978344573 -114636644 175964339 -130065262 175964339 618218908 978344573 595683272 978344573 -59112982 -59112982 407903716 -470557486 407903716 978344573 982942392 -161719298 -161719298 -77218969 744540226 840698750 840698750 -351586774 406080468 -896965567 406080468 840698750 840698750 897482274 -383473106 897482274 904058705…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Chetan's Granite Ledger - MEDIUM Coding Problem | CodeTikki