+ 2
Give me the best way to reverse the elements in the list [1,3,4,7,8,5,6,2,9] without using built-in functions in any language?
8 odpowiedzi
+ 10
Please show us your attempt, so that we can see what you have done so far. So it would be nice, if you could link your code here. Thanks.
+ 5
#python
a = list(range(10))
a = [a.pop() for _ in range(len(a))]
Anyway one possible algorithm is make a loop that goes from 0 to half of the list size. Swap the first element with the last. Then swap the second element with the second from the back. And so on. You can use a temp var for swapping.
+ 4
shouldn't it be without built-ins? 🤔
+ 4
Sudhakara Bathala Here we can do in Java like this
https://code.sololearn.com/c4cKNI5j4LjQ/?ref=app
+ 3
Traverse the list backwards and copy each element into a new list.