Simple Ruby Solution


  • 1
    F
    def reverse_str(s, k)
    	for i in (0 ... s.length).step k*2
    		s[i ... i+k] = s[i ... i+k].reverse
    	end
    	s
    end
    

    Enjoy!


Log in to reply
 

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