fork download
  1. def getMax v, lo, hi
  2.  
  3. if lo == hi
  4. v[lo]
  5. else
  6.  
  7. mid = (lo + hi)>>1
  8. a, b = getMax(v, lo, mid), getMax(v, mid + 1, hi)
  9. a > b ? a : b
  10.  
  11. end
  12.  
  13. end
  14.  
  15. vec = [11,33,44,333,111,88,55,233,1111,88888,5555]
  16.  
  17. max = getMax(vec, 0, vec.length() - 1)
  18.  
  19. p max
Success #stdin #stdout 0.01s 6408KB
stdin
Standard input is empty
stdout
88888