about | help | code help+videos | done | prefs |
Given a Stack of integers, return the integer that is on the top of the stack. If the stack has no elements, return 0. YOUR FIRST TWO LINES OF CODE MUST BE: Stack<Integer> stack = new Stack<Integer>(); stack.addAll(list); stack_peekStack([5, 4, 3, 2, 1]) → 1 stack_peekStack([5, 4, 3]) → 3 stack_peekStack([5]) → 5 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy