Skip to content

Instantly share code, notes, and snippets.

View heartfulbird's full-sized avatar
💭
Ruby On Rails | Full Stack

Stanislav Savickii heartfulbird

💭
Ruby On Rails | Full Stack
View GitHub Profile
# this one should be optimized in terms of memory usage
def reverse(arr = [])
reversed = []
# here we remove the element from the original array and write it to the reversed one
arr.length.times { |i| reversed.push arr.pop }
reversed
end