Episode 19 – Reversing an array

The Code Snippets Podcast
The Code Snippets Podcast
Episode 19 - Reversing an array
/

Today I talk about reversing an array

https://leetcode.com/problems/reverse-linked-list

If SQUID GAME was made for Software Engineers – Ep 2: FAANG

def reverse_list(head)
    if head.nil?
        return head
    end
    newindex = head.length-1
    newhead = []
    head.each_with_index do |vaule, i|
        newhead[newindex] = vaule
        newindex=newindex-1
    end
    return newhead
end