To Lower Case

Description

Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.

Example 1:

Input: "Hello"
Output: "hello"

Example 2:

Input: "here"
Output: "here"

Example 3:

Input: "LOVELY"
Output: "lovely"

Discuss

直接遍历就可以

Code

class Solution {
public String toLowerCase(String str) {
if (str == null || str.length() == 0) { return null; }
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c >= 'A' && c <= 'Z') {
c += 32;
sb.append(Character.toString((char)c));
continue;
}
sb.append(c);
}
return sb.toString();
}
}

【Leetcode】709. To Lower Case的更多相关文章

  1. 【LeetCode】709. To Lower Case 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 ASIIC码操作 日期 题目地址:https:// ...

  2. 【Leetcode_easy】709. To Lower Case

    problem 709. To Lower Case solution1: class Solution { public: string toLowerCase(string str) { stri ...

  3. 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)

    [LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...

  4. Leetcode#709. To Lower Case(转换成小写字母)

    题目描述 实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串. 示例 1: 输入: "Hello" ...

  5. 709. To Lower Case - LeetCode

    Question 709. To Lower Case Sollution 题目大意:字符串大写转小写 思路: 直接调用Java API函数 字符串转char数组,遍历数组,判断如果大写就转小写 Ja ...

  6. 【LeetCode】392. Is Subsequence 解题报告(Python)

    [LeetCode]392. Is Subsequence 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/is-subseq ...

  7. 【leetcode】657. Robot Return to Origin

    Algorithm [leetcode]657. Robot Return to Origin https://leetcode.com/problems/robot-return-to-origin ...

  8. 【LeetCode】代码模板,刷题必会

    目录 二分查找 排序的写法 BFS的写法 DFS的写法 回溯法 树 递归 迭代 前序遍历 中序遍历 后序遍历 构建完全二叉树 并查集 前缀树 图遍历 Dijkstra算法 Floyd-Warshall ...

  9. 【LeetCode】Gas Station 解题报告

    [LeetCode]Gas Station 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/gas-station/#/descr ...

随机推荐

  1. xtrabackup 备份恢复

    XtraBackup物理备份 Percona XtraBackup是世界上唯一的开源,免费的MySQL热备份软件,为InnoDB和XtraDB 数据库执行非阻塞备份.使用Percona XtraBac ...

  2. Locust性能测试1 脚本编写与运行

    按照官网的quickstart编写脚本并运行 1  编写脚本 2  locust -f  filepath 启动locust 3 浏览器打开localhost:8089,设置并发用户数和每秒启动用户数 ...

  3. 用批处理在windows中导出/导入无线网络信息,复制保存为bat即可

    @echo offtitle 在windows中导出/导入无线网络信息 :Beginecho ========================echo 请选择操作:echo 1 查看可用的无线网络ec ...

  4. bootstrapTable refresh 方法使用简单举例

    本文就bootstrapTable refresh 方法如何传递参数做简单举例说明. 下面代码中,一个table,一个button,单击button会触发刷新表格操作. <!DOCTYPE ht ...

  5. Flexbox 布局的最简单表单

    作者: 阮一峰 日期: 2018年10月18日 弹性布局(Flexbox)逐渐流行,越来越多人使用,因为它写 CSS 布局真是太方便了. 三年前,我写过 Flexbox 的介绍(上,下),但是有些地方 ...

  6. POJ 1984 Navigation Nightmare 【经典带权并查集】

    任意门:http://poj.org/problem?id=1984 Navigation Nightmare Time Limit: 2000MS   Memory Limit: 30000K To ...

  7. PSROIAlign的代码实现

    https://github.com/afantideng/R-FCN-PSROIAlign

  8. apache 配置跨域访问

    在httpd.conf找到  去掉# LoadModule headers_module modules/mod_headers.so 然后在 独立域名配置 加入 Header set Access- ...

  9. Blog 使用Jsoup解析出html中的img元素

    Jsoup主页:http://jsoup.org/ 在Blog.java 加入 private List<String> imageList=new LinkedList<Strin ...

  10. 【luogu P3373 线段树2】 模板

    题目链接:https://www.luogu.org/problemnew/show/P3373 lazy标记两个,先乘后加 #include <iostream> #include &l ...