CT32793

Northern stretches Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the alabaster quarry of Whitestone close for winter, Harish must finish the stretches ledger - one figure at a time. Task: Print the maximum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the maximum window sum. Constraints: 1 <= k <= n <= 3462; -1000000 <= a[i] <= 1000.

Example 1:

Input: 2104 253 -433456 -833930 -276077 -632399 -138063 -907262 -958735 -633162 -468138 -741060 -576291 -476900 -795768 -336104 -348834 -915234 -168320 -201698 -949432 -732058 -925425 -709171 -647260 -621372 -442790 -569707 -203501 -447200 -724005 -631473 -688627 -715592 -269459 -873645 -972937 -101071 -166022 -200506 -266317 -113120 -823500 -627949 -515098 -421221 -7662 -102553 -785786 -999237 -680006 -906407 -525383 -160306 -19606 -219360 -614867 -75738 -291983 -744252 -608846 -624301 -817182 -879363 -574435 -74132 -301814 -753565 -503532 -393442 -697129 -271146 -155084 -546685 -768650 -53657 -339100 -980797 -198930 -152535 -714432 -89188 -247261 -627455 -716687 -346288 -648956 -536006 -237697 -624321 -714147 -982092 -654146 -295820 -388054 -403202 -631423 -589698 -932138 -385131 -5589 -132981 …
Output: -117252618

Example 2:

Input: 3034 2597 -416418 -628086 -104387 -14432 -930596 -580261 -103994 -548368 -50155 -875861 -557152 -139938 -249338 -141954 -130482 -646184 -434234 -207475 -112212 -350402 -836701 -899389 -621314 -75782 -698508 -48493 -346324 -511416 -154244 -448725 -727370 -418461 -854440 -897847 -914306 -898049 -680588 -546239 -723342 -545854 -171993 -88709 -413040 -262100 -258386 -41008 -187457 -874251 -176661 -531168 -444420 -454735 -183700 -748581 -659738 -720730 -341710 -654505 -567091 -419572 -106974 -198892 -267944 -965804 -249813 -621790 -146703 -241016 -79360 -275788 -695459 -42501 -516082 -973733 -536785 -685881 -22139 -624481 -506281 -286017 -899963 -208851 -10794 -271635 -33426 -740851 -604579 -504109 -985641 -739627 -430795 -146759 -566476 -658372 -34593 -701404 -763675 -643144 -963328 -283146 -4…
Output: -1263290221

Example 3:

Input: 1285 1135 -594561 -381490 -754101 -952963 -228035 -953030 -234260 -636663 -549850 -874822 -506751 -62139 -539204 -320032 -942453 -143000 -897870 -238698 -512297 -773735 -359913 -500341 -411868 -730026 -20424 -806210 -55000 -219672 -910705 -168548 -494820 -214766 -847426 -593514 -491824 -88044 -487063 -425867 -496797 -467489 -818761 -985498 -590201 -907431 -739433 -572353 -405836 -282437 -106661 -98234 -493140 -810447 -848214 -731641 -581538 -565194 -505104 -7862 -549165 -225598 -856529 -335760 -98940 -240871 -22708 -78073 -420091 -424506 -892861 -241827 -245079 -926517 -461684 -617633 -614514 -545828 -909912 -253511 -463896 -463976 -414413 -743094 -806553 -30897 -660649 -131512 -867889 -484842 -161953 -360609 -491859 -833964 -583576 -35413 -142398 -220017 -839549 -169062 -554510 -319333 -8…
Output: -571965794

Constraints:

1 <= k <= n <= 3462; -1000000 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
Northern stretches Fixed Window Peak - MEDIUM Coding Problem | CodeTikki