GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Leetcode-Algorithms/src/leetcode/ReverseString.java at master · edyluisrey/Leetcode-Algorithms Expand file tree/ Copy pathReverseString.javaMore file actions 22 lines (18 loc) · 459 Bytes / Copy pathReverseString.javaFile metadata and controls22 lines (18 loc) · 459 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 package leetcode; public class ReverseString { public static void main(String[] args) { ReverseString test = new ReverseString(); System.out.println(test.reverseString("hello")); } public String reverseString(String s) { if(s.length()==0) return s; char[] str= s.toCharArray(); int n= str.length; for(int i= 0; i<n/2;i++){ char temp = str[i]; str[i]=str[n-1-i]; str[n-1-i] = temp; } return String.valueOf(str); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |