Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Functions {
- //Targil 1
- public static Stack<Integer> stacksToStackSums(Stack<Queue<Integer>> stackOfQueues)
- {
- int sum = 0;
- Queue<Integer> temp;
- Stack<Integer> stackSum = new Stack<Integer>();
- while(!stackOfQueues.isEmpty())
- {
- sum = 0;
- temp = stackOfQueues.pop();
- while(!temp.isEmpty())
- {
- sum += temp.remove();
- }
- stackSum.push(sum);
- }
- return stackSum;
- }
- public static boolean stackEqualsNode(Node<Character> node, Stack<Character> stack)
- {
- Stack<Character> temp = StackFunctions.duplicate(stack);
- while(!temp.isEmpty())
- {
- if(!NodeFunctions.isInNode(node, temp.pop()))
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment