【LeetCode】解析_709. To Lower Case

轉變小寫

參考及出處網站:Leetcode

思路:我的想法是從ASC||碼著手 

我的想法是把他轉成ASC|| 再加上32 再轉回char;

  public static string ToLowerCase(string str)
        {
            string capitalText = str;
            int cNum = 0;
            string lowercaseText = "";
            foreach (char c in capitalText)
            {
                cNum = Convert.ToInt32(c);
                if (cNum >= 65 && cNum <= 90)
                {
                    cNum += 32;
                }
                char character = (char)cNum;
                lowercaseText += character;
            }
            return lowercaseText;
        }

但看下來 其實這樣解好像不優~

Runtime: 100 ms, faster than 56.42% of C# online submissions for To Lower Case.

Memory Usage: 7.7 MB, less than 3.98% of C# online submissions for To Lower Case.

主要是做我的學習筆記

偶而心血來潮寫個幾篇~

若有問題~可以寫信或在下方留言~感謝