We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Tutorials
- 30 Days of Code
- Day 7: Arrays
- Discussions
Day 7: Arrays
Day 7: Arrays
+ 0 comments C#
using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.Serialization; using System.Text.RegularExpressions; using System.Text; using System; class Solution { public static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine().Trim()); List<int> arr = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(arrTemp => Convert.ToInt32(arrTemp)).ToList(); reverse(arr); } static void reverse(List<int> arrs) { int[] toArray = arrs.ToArray(); Array.Reverse(toArray); foreach(int arr in toArray) { Console.Write(arr + " "); } } }
+ 0 comments if __name__ == '__main__': n = int(input().strip()) arr = list(map(int, input().rstrip().split())) print(*[arr[i] for i in reversed(range(n))], sep=" ")
+ 0 comments Efficiently!
for i in range(1, len(arr)+1): print(arr[-i], end=' ')
+ 0 comments Solution in python
#only add this line of code will do the work print(' '.join(map(str, arr[::-1])))
+ 0 comments C# solution:
arr.Reverse(); Console.WriteLine(String.Join(" ", arr));
Load more conversations
Sort 1966 Discussions, By:
Please Login in order to post a comment