tow methods, layer-by-layer cost O(n*longest), split into 3 area costs O(n)