Ruby solution


  • 0
    G
    def reverse_string(s)
        be=0
        e=s.length-1
        while be < e 
            temp=s[e]
            s[e]=s[be]
            s[be]=temp
            be+=1
            e-=1
        end
        s
    end
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.