当前位置:网站首页>709. Convert to lowercase letters
709. Convert to lowercase letters
2022-07-24 16:37:00 【My_ Bells】
Title Description
Implementation function ToLowerCase(), This function takes a string parameter str, And convert the upper case letters in the string to lower case letters , Then return the new string .
https://leetcode-cn.com/problems/to-lower-case/
Their thinking
There are two ways to achieve :
- Call directly js In the string toLowerCase Method realization .
- A-Z Of ASCII The value is 65-90.a-z The value is 97-122. In lowercase ASCII Value is its corresponding capital letter ASCII Value plus 32.
Code implementation
/** * @param {string} str * @return {string} */
//1.toLowerCase 88 ms 33.8 MB
var toLowerCase = function(str) {
return str.toLowerCase();
};
//A~Z Of ASCII The value is 65~90.
//a~z Of ASCII The value is 97~122.
// In lowercase ASCII Value is its corresponding capital letter ASCII Value plus 32. 64 ms 33.7 MB
var toLowerCase = function(str) {
let res='';
for(let i=0;i<str.length;i++){
let code=str.charCodeAt(i);
if(code>=65&&code<=90){
res+=String.fromCharCode(code+32);
}else{
res+=str[i];
}
}
return res;
str.toLowerCase
};
边栏推荐
- Servlet框架(servlet+jsp)+Mysql实现的增删改查+分页(功能包学生信息录入、学生信息增删改查、分页等)
- 多线程(基础)
- What does Baidu promote "delete and recall" mean?
- Minor record
- Custom view - Custom button
- JUC source code learning note 3 - AQS waiting queue and cyclicbarrier, BlockingQueue
- [leetcode]75. color classification - problem solving (execution time beat 90%, memory consumption beat 78%)
- 剑指 Offer 22. 链表中倒数第k个节点
- OpenMP入门
- 随笔记:同步、异步和微任务、宏任务的打印顺序
猜你喜欢

ARP 入门

leetcode:162. 寻找峰值【二分寻找峰值】

Custom view - Custom button

EMQ Yingyun technology was listed on the 2022 "cutting edge 100" list of Chinese entrepreneurs
[email protected]"/>ZBar project introduction and installation configuration| [email protected]

15、ARM嵌入式系统:如何用PC调试单板

Long awaited full platform support - Open Source im project uniapp update of openim

VSCode如何鼠标滚轮放大界面

1184. 公交站间的距离

会议OA项目进度(一)
随机推荐
Jupyter uses tips
1184. 公交站间的距离
Leetcode:162. looking for peak [two points looking for peak]
Getting started with arcpy
Qt设计机器人仿真控制器——按键控制机器人关节转动
普林斯顿微积分读本02第一章--函数的复合、奇偶函数、函数图像
Unity camera free movement control
安全的证券公司有哪些?我想在手机上买股票
Creation and inheritance of JS class
Codeforces round 690 (Div. 3) B. last year's substring conventional solution
What is the difference between cookies, localstorage and sessionstorage?
ArcGIS pixel size changed from 0.00025 to meters
简单使用 MySQL 索引
JS, call in the for loop is asynchronously converted to synchronous execution
Druid integration shardingsphere appears xxmapper Reasons and solutions of XML error reporting
Zcmu--5023: family division (C language)
thinkphp3.2.5无法跳转到外部链接
Solution to deepin taskbar disappearance
Wechat applet list (list rendering of data rendering)
Dongfang Guangyi refuted the rumor late at night, saying that the news that the hammer was filed for investigation was untrue!