max - Maximum Value of subarray -



max - Maximum Value of subarray -

is there function returns maximum number subarray of longint array?

for example:

i have array: [2,3,6,2,9,4,2,4]

i want maximum value of first 5 elements [2,3,6,2,9] of array (9)

which best solution?

you don't need create array. 1st solution come loop within array, taking first value 'tempmaxvalue', , fetching array comparing each value 'tempmaxvalue'.

if value greater 'tempmaxvalue', update 'tempmaxvalue' particular value , jump next value in array, otherwise jump next value.

with solution, can manage number of items want search (here wanted greatest number within 5 first elements, loop go 0 4)

edit : (as @tlama said)

max pascal freepascal arrays

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -