You are viewing a single comment's thread. Return to all comments →
def gridlandMetro(n, m, k, track) minMax = Hash.new(-1) track.each do |line| minMax[line[0]] = [] if minMax[line[0]] == -1 minMax[line[0]] << [line[1], line[2]] end counter = 0 minMax.values.each do |line| line.sort! while not line.empty? start_point, end_point = line.shift end_point = [line.shift[1], end_point].max while not line.empty? and line[0][0] <= end_point counter += end_point - start_point + 1 end end m*n - counter end
Seems like cookies are disabled on this browser, please enable them to open this website
Gridland Metro
You are viewing a single comment's thread. Return to all comments →
Ruby