Skip to content

Instantly share code, notes, and snippets.

@vrat28
Created May 24, 2021 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrat28/45bd18bedfa6b5e5224716bb559f7e26 to your computer and use it in GitHub Desktop.
Save vrat28/45bd18bedfa6b5e5224716bb559f7e26 to your computer and use it in GitHub Desktop.
To Lower Case
class Solution {
func toLowerCase(_ s: String) -> String {
var result = ""
for c in s {
var letter = c
if c >= "A", c <= "Z" {
letter = toLower(c)
}
result += "\(letter)"
}
return result
}
func toLower(_ character:Character) -> Character {
let asciiValue:UInt8 = character.asciiValue! + 32
return Character(UnicodeScalar(asciiValue))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment