We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Surprisingly pass with O(n^4) solution.
Read triangular(N) input.
Compute all tetrahedral(N) subtriangles in O(n^3).
Each subtriangle cost O(n). Could be O(1) by subtracting pre-computed row of sum.
Sort all subtriangles and print first K.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #150: Searching a triangular array for a sub-triangle having minimum-sum.
You are viewing a single comment's thread. Return to all comments →
Surprisingly pass with
O(n^4)
solution.Read
triangular(N)
input.Compute all
tetrahedral(N)
subtriangles inO(n^3)
.Each subtriangle cost
O(n)
. Could beO(1)
by subtracting pre-computed row of sum.Sort all subtriangles and print first
K
.