public class Solution { public string ToLowerCase(string str) { var sb = new StringBuilder(str); for (var i = 0; i < sb.Length; ++i) { char c = sb[i]; if (c >= 'A' && c <= 'Z') { sb[i] = (char)(c + ('a' - 'A')); } } return sb.ToString(); } }Source: https://leetcode.com/problems/to-lower-case/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Sunday, February 21, 2021
Leetcode Everyday: 709. To Lower Case. Easy
It's in the rules not to use the built-in method. Here's a solution without using the built-in method
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment