You are viewing a single comment's thread. Return to all comments →
Solution in c#
static void Main(String[] args) { var tt = Convert.ToInt32(Console.ReadLine()); for(int i=0; i<tt; i++) { var list = new List<List<int>>(); var loop = Convert.ToInt32(Console.ReadLine()); for(int j=0; j<loop;j++) { var current = Console .ReadLine() .Trim() .ToString() .Split(' ') .Select(x=>Convert.ToInt32(x)) .ToList(); list.Add(current); } for (var m = list.Count - 2; m >= 0; m--) { for (var n = 0; n <= m; n++) { list[m][n] += Math.Max(list[m + 1][n], list[m + 1][n + 1]); } } Console.WriteLine(list[0][0]); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #67: Maximum path sum II
You are viewing a single comment's thread. Return to all comments →
Solution in c#