Leetcode: To Lower Case (Kotlin)
Leetcode: To Lower Case (Kotlin)
This is an easy Linked List problem on Leetcode. I will go through my thought process for solving this in Kotlin. To Lower Case - LeetCode
Problem Statement
Examples
Constraints
Techniques to solve this problem
In this problem, you are given a string containing uppercase and lowercase letters and are asked to convert the string to lowercase.
-
One possible approach is to iterate through the characters in the string and convert each uppercase character to lowercase by adding 32 to the current character.
-
First, define the function to take a string as an argument and return a lowercase version of the string.
-
Inside the function, iterate through the characters in the string and check if the character is uppercase by converting the character to an int and checking if it is bigger or equal to 65 (A) or less than or equal to 90 (Z). We can also specify the character directly. Both examples will be posted below.
-
Convert each uppercase character to lowercase by adding 32 to the current character.
-
When the loop is finished, call toString() on the StringBuilder object and return it.
Solutions
{% gist https://gist.github.com/cmcoffeedev/25a9e812a5625c15c8a3aaea11d5045e.js %}{% gist https://gist.github.com/cmcoffeedev/9eb16ad26a230a9a7ab6f856494955f5.js %}