CT23848

Kavi's Largest Step Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

At the granite steps of Stonehallow, Kavi records each tickets in a worn leather ledger. The guild wants answers, not guesses. Task: Read n integers and print the largest absolute difference between two consecutive elements. For n=1 print 0. Input format: First line: n. Second line: n space-separated integers. Output format: Print the maximum consecutive absolute difference. Constraints: 1 <= n <= 284; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 252 597 733 540 597 442 529 937 391 748 870 15 922 946 297 142 506 769 163 989 731 272 408 156 62 589 429 702 613 113 463 424 801 928 42 855 534 234 363 988 676 770 514 828 668 455 146 271 548 118 922 742 402 463 870 98 402 405 409 830 32 438 911 900 962 969 686 233 755 548 972 17 688 900 472 929 497 505 509 126 455 669 171 181 854 422 625 962 243 466 326 775 575 288 889 292 858 538 495 284 651 863 298 660 588 4 613 815 12 326 444 428 450 840 138 935 446 267 923 239 441 32 47 521 273 892 371 342 837 137 162 214 696 262 264 215 163 146 152 366 498 179 340 330 575 824 26 16 359 367 141 104 503 640 4 815 558 661 28 617 77 78 603 762 272 640 190 189 779 195 742 34 115 500 456 299 163 224 837 965 549 911 154 134 137 188 705 631 19 616 678 715 755 544 174 709 630 757 347 38 234 36 58 175 541 534…
Output: 955

Example 2:

Input: 158 30 428 321 764 507 557 53 690 551 74 741 73 668 292 603 565 318 402 956 228 240 885 719 82 116 12 774 662 795 462 784 131 649 773 264 8 656 241 143 75 452 774 34 535 701 998 498 934 138 469 18 403 75 398 376 991 185 271 421 745 991 370 419 137 234 186 950 265 9 160 606 555 98 97 671 607 223 291 522 634 58 236 397 538 904 874 22 136 610 29 706 436 679 980 243 437 704 59 958 50 391 955 676 551 259 917 617 461 538 142 706 852 568 952 45 315 873 389 972 955 118 747 429 632 497 225 623 975 65 338 975 232 911 85 165 649 887 213 339 570 703 53 510 646 185 422 384 933 186 154 666 423 676 302 102 597 508 176
Output: 910

Example 3:

Input: 76 739 605 195 152 959 228 229 687 640 473 539 554 531 773 815 19 25 751 100 796 175 306 206 337 86 397 253 267 512 941 622 928 943 980 701 253 171 404 576 133 933 240 933 610 570 64 598 691 421 852 702 931 839 883 684 576 31 690 88 707 958 597 631 399 773 731 313 681 666 955 787 280 637 817 472 434
Output: 807

Constraints:

1 <= n <= 284; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Loading...
Test Cases:No test cases
No test cases available.
Kavi's Largest Step Ledger - EASY Coding Problem | CodeTikki