This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function reverse_array(arr, start, end){ | |
| if (start >= end){ | |
| return | |
| } | |
| var temp = arr[start]; | |
| arr[start] = arr[end]; | |
| arr[end] = temp; | |
| reverse_array(arr, start+1, end-1); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ReverseNum{ | |
| static void rvereseArray(int arr[], int start, int end) | |
| { | |
| int temp; | |
| if (start >= end) | |
| return; | |
| temp = arr[start]; | |
| arr[start] = arr[end]; | |
| arr[end] = temp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def reverse_array(arr, start, end): | |
| if start >= end: | |
| return | |
| arr[start], arr[end] = arr[end], arr[start] | |
| reverse_array(arr, start+1, end-1) | |
| nums = [1, 2, 3, 4, 5] | |
| total_nums = len(nums) | |
| reverse_array(arr=nums, start=0, end=len(nums)-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var arr = [1, 3, 4, 5, 6]; | |
| for (var itr=0; itr< arr.length/2 ; itr++){ | |
| var temp = arr[itr]; | |
| arr[itr] = arr[arr.length-1-itr]; | |
| arr[arr.length-1-itr] = temp; | |
| } | |
| console.log(arr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ReverseNum{ | |
| public static void main(String []args){ | |
| int arr[] = {1, 2, 3, 4, 5, 6}; | |
| for (int itr=0; itr<arr.length/2 ;itr++){ | |
| int temp = arr[itr]; | |
| arr[itr] = arr[arr.length-1-itr] ; | |
| arr[arr.length-1-itr] = temp; | |
| } | |
| for(int itr=0; itr<6; itr++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nums = [1, 2, 3, 4, 5] | |
| total_nums = len(nums) | |
| for itr in range(total_nums//2): | |
| temp = nums[itr] | |
| nums[itr] = nums[total_nums-itr-1] | |
| nums[total_nums-itr-1] = temp | |
| print(nums) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var input = [1, 2, 3, 4, 5]; | |
| var output = []; | |
| for(var itr=input.length;itr>=0;itr--){ | |
| output.push(input[itr-1]); | |
| } | |
| console.log(output); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ReverseNum{ | |
| public static void main(String []args){ | |
| int arr[] = {1, 2, 3, 4, 5, 6}; | |
| int output_array[]=new int[6]; | |
| for (int itr=0, ctr=5; ctr >=0; ctr--, itr++){ | |
| output_array[itr] = arr[ctr]; | |
| } | |
| for(int itr=0; itr<6; itr++){ | |
| System.out.println(output_array[itr]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nums = input().split(",") | |
| total_elem = len(nums) | |
| output_nums = list() | |
| while total_elem: | |
| ouput_nums.append(nums[total_elem-1]) | |
| total_elem -= 1 | |
| print(output_nums) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node: | |
| def __init__(self, data): | |
| self.item = data | |
| self.nref = None | |
| self.pref = None |