Write a function that takes a string as input and returns the string reversed.
翻译:写一个函数,输入一个字符串,返回反转的字符串。
分析:
大水题,转为字符数组,然后直接用系统内置函数反转后再变为字符串,顺利AC。
1 public class Solution 2 { 3 public string ReverseString(string s) 4 { 5 char[] arr = s.ToCharArray(); 6 Array.Reverse(arr); 7 return new string(arr); 8 } 9 }
没想到效率还挺高,运行时间打败了90.03%的人。