8463277740

8463277740



Given array of mtegers fmd the maximal possible sum of some of its k consecutive elements Example

for array - (2, 3, 5, i, 6]. k - 2 output should be 8

•    [input] array.integer inputArray

o array of posrtive mtegers

•    [input] integer k

o an integer (not greater than the length of inputArray )

•    [output] integer

o the maximal possible sum

: O


©0O



COOE

1* arrayflaxConse<utiveSu«( [J InputArray, k) { 2

3 *    result - 0,

4    rurrpntSua - 0;

5

6»    (    i - 0; i < k - 1; i++) {

7    currentSura    ♦-    inputArray[i];

8    ł

9*    (    i - k - 1; i < inputArray.length; i**) {

10    currentSua    ♦»    ... ;

11 *    i i (currentSua > result) {

12    result    -    currentSua;

13    ł

14    currentSua    --    inputArray[i    - k ♦ 1];

15    }

16

17    Hrt    result;

18    }

19




Wyszukiwarka

Podobne podstrony:
CDF4 ScheduleSpecify the channel scheduling information If the Schedule element (or any of its child
m850 possibly by only some of the latter: it was never as common as we are given to believe. Only a
Quick Test Setup of MySQL Cluster To familiarize you with the basics, we will describe the simplest
214 M. Odlamcka-Poczobutt commerce is delivering the greater possibility of choice of goods or servi
6.    The idea of workers self-management has given a new offensive strategy to
Mutual Information of Discrete Memoryless Channel (DMC) For the given, set of input messages: X = [x
DNIAf. IW ARCMBISHOPS MOUSE. WESTWINSTER LOHDON.5 W I aDDRESS GIVEN BY HIS SHA.CE THE ARCHBISHOP OF
ape 016 ■ 6    ANDERSONA PHYSICAL EBUCATION. have it in the bcst possible condition.
EICO’s New Transistor Portable ONE of the recent portable radio kits to make its appearance on the m
Summary PhD thesis presents analysis of RCM maintenance system implementation for the semi submersib
2. The Paediatric Committee shall draw up its rules of procedurę for the implementation of its tasks
1. INTRODUCTION The results of various accident scenario simulations for the two major MHTGR variant
Abstract There are presented the results of the studies of the subsurface zonę created in aluminium

więcej podobnych podstron