You are viewing a single comment's thread. Return to all comments →
c# solution :
public static List<int> getMax(List<string> operations) { var stackList = new List<int>(); var maxList = new List<int>(); foreach (var op in operations) { var splitList = op.Split(" ").Select(x => Convert.ToInt32(x.Trim())).ToList(); var opType = splitList[0]; switch (opType) { case 1: stackList.Add(splitList[1]); break; case 2: stackList.RemoveAt(stackList.Count - 1); ; break; case 3: maxList.Add(stackList.Max()); break; } } return maxList; }
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
c# solution :