study of max subarray problem in ruby