【Leetcode】To Lower Case
題目大意:把所有的大寫字母轉化為小寫字母
解題方法:判斷字元是否在‘A’-‘Z’中,如果是,則轉換為小寫,如果不是,保留不變既可
Python解法:
class Solution(object): def toLowerCase(self, str): """ :type str: str :rtype: str """ res = "" for s in str: if ord(s) >= ord('A') and ord(s) <= ord('Z'): res += chr(ord(s)- ord('A') + ord('a')) else: res += s return res
這題也可以直接用lower()函式直接實現;
相關推薦
【Leetcode】To Lower Case
題目大意:把所有的大寫字母轉化為小寫字母 解題方法:判斷字元是否在‘A’-‘Z’中,如果是,則轉換為小寫,如果不是,保留不變既可 Python解法: class Solution(object): def toLowerCase(self, str):
[LeetCode]709. To Lower Case
out parameter imp () inpu love ++ strong UNC Implement function ToLowerCase() that has a string parameter str, and returns the same strin
[LeetCode] 709. To Lower Case(C++)
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Input: "Hello" Out
leetcode 709. To Lower Case(水,大寫轉小寫)
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowe
leetcode ( To Lower Case)
Title: To Lower Case 709 Difficulty:Easy 原題leetcode地址: https://leetcode.com/problems/to-lower-case/ 1. 大寫字元加3
LeetCode 709 To Lower Case 解題報告
題目要求 Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. 題目分析及思路 題目要求返回一個字串的小寫形式。可以直接使用lower()函式
Leetcode——709. To Lower Case
題目原址 題目描述 Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Exampl
LeetCode 709 To Lower Case 轉換成小寫字母
class Solution { public: string toLowerCase(string str) { for(auto &c:str) { if(c>='A' && c
LeetCode 709.To Lower Case
字母 put NPU 轉化 沒有 運行 des image 分享 Description Implement function ToLowerCase() that has a string parameter str, and returns the same strin
【Leetcode】709. To Lower Case
clas esc scrip int builder cte func pre 遍歷 To Lower Case Description Implement function ToLowerCase() that has a string parameter str, an
【LeetCode】709. To Lower Case題解(C++)
【LeetCode】709. To Lower Case(C++) 709. To Lower Case Describe: Implement function ToLowerCase() that has a string parameter str, a
【LeetCode】709(Java)To Lower Case
Question: Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. 實現函式ToLowerCase st
【LeetCode】241. Different Ways to Add Parentheses
cto only leetcode save ++ ssi brush log ive 題目: Given a string of numbers and operators, return all possible results from computing all t
【leetcode】Flatten Binary Tree to Linked List
模式 分析 事情 oot left stat log 這樣的 要求 分析: 問題是將給定的二叉樹變換成令一種形式,這樣的類型的問題。其模式是,將左子樹變換成某種形式
【LeetCode】013. Roman to Integer
BE ant dot range 不能 code action lin get Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range fr
【LeetCode】012. Integer to Roman
rom pan lee style roman post 連續 ive res Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range fro
【LeetCode】115.Best Time to Buy and Sell Stock
題目描述(Easy) Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to co
【LeetCode】116.Best Time to Buy and Sell Stock II
題目描述(Easy) Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the
【LeetCode】123.Best Time to Buy and Sell Stock III
題目描述(Hard) Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the
C#LeetCode刷題之#709-轉換成小寫字母(To Lower Case)
問題 實現函式 ToLowerCase(),該函式接收一個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。 輸入: "Hello" 輸出: "hello" 輸入: "here" 輸出: "here" 輸入: