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
Post a Comment