Is the space complexity of this algorithm is O(n^3) cubic space complexity ? As: list is an array, subs is an array + one array created with map.
Is the time complexity is O(n^4) biquadratic? As: two times loop on list + one time map + one time sum
def largest_contiguous_subsum(list)
subs = []
list.each_index do |idx1|
(idx1..list.length - 1).each do |idx2|
subs << list[idx1..idx2]
end
end
subs.map(&:sum).max
end
I am currently trying to understand Big O concept