Leetcode709.To Lower Case轉換成小寫字母
實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。
示例 1:
輸入: "Hello" 輸出: "hello"
示例 2:
輸入: "here" 輸出: "here"
示例 3:
輸入: "LOVELY" 輸出: "lovely"
class Solution { public: string toLowerCase(string str) { int len = str.size(); if(len == 0) return str; for(int i = 0; i < len; i++) { if(str[i] >= 'A' && str[i] <= 'Z') { str[i] = 'a' + str[i] - 'A'; } } return str; } };
相關推薦
Leetcode709.To Lower Case轉換成小寫字母
實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 示例 1: 輸入: "Hello" 輸出: "hello" 示例 2: 輸入: "here" 輸出: "here" 示例 
LeetCode 709 To Lower Case 轉換成小寫字母
class Solution { public: string toLowerCase(string str) { for(auto &c:str) { if(c>='A' && c
C#LeetCode刷題之#709-轉換成小寫字母(To Lower Case)
問題 實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 輸入: "Hello" 輸出: "hello" 輸入: "here" 輸出: "here" 輸入:
leetcode 709. 轉換成小寫字母(To Lower Case)
string return class lis 函數 目錄 res lower 大寫 目錄 題目描述: 示例 1: 示例 2: 示例 3: 解法:
leetcode - 709 - 轉換成小寫字母
class Solution: def toLowerCase(self, str): """ :type str: str
【LeetCode】709. 轉換成小寫字母
實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 示例 1: 輸入: “Hello” 輸出: “hello” 示例 2: 輸入: “here” 輸出: “here”
leetcode.709 轉換成小寫字母
實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 示例 1: 輸入: "Hello" 輸出: "hello" 示例 2: 輸入: "here" 輸出: "here" 示例 3
leetcode題庫——轉換成小寫字母
不想寫題日常打卡湊題數系列...... 題目描述: 實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 示例 1: 輸入: "Hello" 輸出: "hello" 示例 2: 輸入: "here"
[leetcode]轉換成小寫字母
709. 轉換成小寫字母 實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 示例 1: 輸入: "Hello" 輸出: "hello" 示例 2: 輸入: "here" 輸出: "here
【LeetCode】 轉換成小寫字母
實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 示例 1: 輸入: "Hello" 輸出: "hello" 示例 2: 輸入: "here" 輸出: "here" 示例 3
leetcode709. To Lower Case
Example 1: Input: "Hello" Output: "hello" Example 2: Input: "here" Output: "here" Example 3: Input: "LOVELY" Output: "lovely" 1
Python實現"轉換成小寫字母"的兩種方法
實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串 Example 1: Input: "Hello" Output: "hello" Example 2: Input: "here" Ou
演算法之709. 轉換成小寫字母
題目:實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 class Solution { public: strin
leetcode709—To Lower Case
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Input: "Hello" Output: "hello" Exam
【LeetCode】轉換成小寫字母
實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 示例 1: 輸入: “Hello” 輸出: “hello” 示例 2: 輸入: “here” 輸出:
如何用C語言將大寫字母轉換成小寫字母其他原樣輸出
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<string.h> #define N 100 int main() { c
input輸入框輸入小寫字母自動轉換成大寫字母有兩種方法
per put 函數 for 小寫 pre 兩種方法 inpu 小寫字母 html裏input加上 <input type="text" id="txt1" value="" onkeyup="toUpperCase(this)"/> js寫函數 f
python 從鍵盤輸入一個字串,將小寫字母全部轉換成大寫字母,將字串以列表的形式輸出(如果字串包含整數取整型)?
str1 = input("請輸入任意字串: ") list1= [] #儲存字串 list2= [] #儲存數字 for i in str1: if i.isdigit() == True: #判斷當前字元是否為字元 list2.append(int(i)) else:
[LeetCode] To Lower Case 轉為小寫
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Input: "Hello"
python3 自己編寫一個程式,把大寫字母轉換為小寫字母(即自程式設計實現了 字串的lower()方法)
#定義一個函式,可以把列表輸入的帶有大寫字母的列表,轉換為全小寫字母 #比如:輸入列表['Hello','worlD','HAHA'] ====> ['hello','world','haha'] #程式碼如下: #定義一個函式,可以把列表輸入的帶有大寫字母的列表