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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -