Answers for "Reverse Array Usign Stack"

0

Reverse Array Usign Stack

public static void reverse(String[] arr){ 

    Stack stack = new Stack();

    for(int i = 0; i < arr.length; i++) {           
        stack.push(arr[i]);

    }
    for(int i = 0; i < arr.length; i++) {
        arr[i] = stack.top();
        stack.pop();     
    }
    return;
}
Posted by: Guest on April-20-2021

Browse Popular Code Answers by Language