CT56610

Xavi's Taller Ahead Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The chronicler Xavi has been asked to secure the caravan contract. On the desk lies a long table of registers readings. 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: 2398 -512158428 859381592 -295893454 351361896 223326705 -289598306 -470325771 224322216 -294424870 109478013 -793853159 511858773 -75780998 -53892214 627736736 166710080 -440910206 -478522020 48995987 454981657 821437224 -77747279 763115159 -142618025 -57350181 992469951 -463654485 249146903 285837599 314656703 -503106566 -482238420 -242813916 -670435904 998421069 -220373359 -249501849 -759277743 233564121 332658805 -224835888 -470415550 407627436 546933616 -131157777 813325158 -169691891 869394332 -324856972 -338751985 -594327579 -994058724 -79660138 -534435172 -748460926 479345835 -898109608 771756207 -312269746 -722754080 -214095382 -950574637 -589522334 38143664 754982080 -239259612 -381097754 881427581 393356436 910421699 817705143 -828673730 104665721 325429036 94869342 554360939 58…
Output: 859381592 992469951 351361896 511858773 224322216 224322216 224322216 511858773 109478013 511858773 511858773 627736736 -53892214 627736736 821437224 454981657 48995987 48995987 454981657 821437224 992469951 763115159 992469951 -57350181 992469951 998421069 249146903 285837599 314656703 998421069 -482238420 -242813916 998421069 998421069 -1 233564121 233564121 233564121 332658805 407627436 407627436 407627436 546933616 813325158 813325158 869394332 869394332 881427581 -79660138 -79660138 -79660138 -79660138 479345835 479345835 479345835 771756207 771756207 881427581 -214095382 -214095382 38143664 -589522334 38143664 754982080 881427581 881427581 881427581 910421699 910421699 963470349 862098070 104665721 325429036 554360939 554360939 585456075 729100844 729100844 862098070 -464843119 -4648…

Example 2:

Input: 234 -298666181 -146396855 -144994648 -715664572 -959734111 -836879318 -137942868 639493872 -969863543 693173878 -435798361 23286499 122410452 -766043486 165466713 528492377 889316784 581917913 -278041071 -469870746 815350097 943683274 -198866821 452685347 204243417 879811984 -915217972 897845358 -227220615 887074474 -776951537 567437533 94914916 317691549 -786173215 -885379722 -789510474 811388565 -282532929 -179451939 -422623483 -773279081 -454014312 -8359470 -464162100 312090098 600877801 -784792630 -197814262 -608530263 374220084 -638814584 584441995 -929545942 72592694 -768000175 396425828 804183151 -758088304 801778847 -441137810 475541274 -269257752 -186870492 -952851659 -911926395 -381208128 -609838080 -683373466 -814516405 949199720 788820653 40705549 267210684 -169134077 -26592290…
Output: -146396855 -144994648 -137942868 -137942868 -836879318 -137942868 639493872 693173878 693173878 889316784 23286499 122410452 165466713 165466713 528492377 889316784 943683274 815350097 815350097 815350097 943683274 949199720 452685347 879811984 879811984 897845358 897845358 949199720 887074474 949199720 567437533 811388565 317691549 811388565 811388565 -789510474 811388565 949199720 -179451939 -8359470 -8359470 -454014312 -8359470 312090098 312090098 600877801 804183151 -197814262 374220084 374220084 584441995 584441995 804183151 72592694 396425828 396425828 804183151 949199720 801778847 949199720 475541274 949199720 -186870492 949199720 -911926395 -381208128 949199720 949199720 949199720 949199720 979429133 790490467 267210684 646118030 -26592290 646118030 742474617 136891419 742474617 74…

Example 3:

Input: 3940 600794795 -913618036 -178433836 658668005 478001366 -808751461 619837453 405852057 63993954 -512549600 789536808 705173008 730072508 -700758487 -667146983 -538162108 -10165737 200524453 -335876614 -762508484 9125780 388751679 -611942995 170806467 141748131 -381591731 -401805091 -456379694 399217719 543089070 222429847 514130667 287261760 661936858 -182018396 -291870579 629428116 875029552 628999313 -85262832 -359095407 -836546814 99743889 442547572 -283824935 580475069 50030552 494413891 -983214763 32316934 -21470107 929036473 758908976 -999018198 -426622302 -271706711 764451792 541304412 -580457968 997253331 255394606 157147265 -762718632 73657712 875171740 -938433803 348507521 143777959 325300492 -209121166 -392832940 -763612513 -742744390 876031379 370035631 94023791 762136252 3389…
Output: 658668005 -178433836 658668005 789536808 619837453 619837453 789536808 789536808 789536808 789536808 875029552 730072508 875029552 -667146983 -538162108 -10165737 200524453 388751679 9125780 9125780 388751679 399217719 170806467 399217719 399217719 399217719 399217719 399217719 543089070 661936858 514130667 661936858 661936858 875029552 629428116 629428116 875029552 929036473 929036473 99743889 99743889 99743889 442547572 580475069 580475069 929036473 494413891 929036473 32316934 929036473 929036473 997253331 764451792 -426622302 -271706711 764451792 997253331 997253331 997253331 997921502 875171740 875171740 73657712 875171740 876031379 348507521 876031379 325300492 876031379 876031379 876031379 -742744390 876031379 896342571 762136252 762136252 896342571 669314799 896342571 896342571 -99…

Constraints:

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

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