Home > Net >  Repeating a Stack using Recursion
Repeating a Stack using Recursion

Time:02-10

I’m trying to print a stack that replaces each integer with two copies of that integer. I figured it out iteratively but I can’t figure it out with recursion using no loops or any other data structures

public static void  repeatStack(Stack<Integer> stack) {
Int size =stack.size();
Int value = stack.remove();
Stack.add(value)
Stack.add(value)

CodePudding user response:

  •  Tags:  
  • Related