当前位置:网站首页>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
};
边栏推荐
- “天上天下,唯我独尊”——单例模式
- Qt设计仿真机器人控制器
- JUC source code learning note 3 - AQS waiting queue and cyclicbarrier, BlockingQueue
- EF combined with sqlbulkcopy batch insert data
- Explain Apache Hudi schema evolution in detail
- Qt键盘事件(一)——检测按键输入
- Envi SHP to ROI and mask the grid
- 1184. Distance between bus stops
- What is the difference between cookies, localstorage and sessionstorage?
- 会议OA项目进度(二)
猜你喜欢

Envi SHP to ROI and mask the grid

Duplicate content in lookup table
[email protected]"/>ZBar source code analysis - img_ scanner. c | [email protected]
![Leetcode:162. looking for peak [two points looking for peak]](/img/77/64b7c9bf1aebc2a0ab82218ddfff62.png)
Leetcode:162. looking for peak [two points looking for peak]

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

如何在 PHP 中防止 XSS

EventLoop event loop mechanism

.NET 测试框架 xUnit,MSTest, Specflow 使用经验汇总

How to generate complex flow chart of XMIND

leetcode:162. 寻找峰值【二分寻找峰值】
随机推荐
The 3D sensing market is accelerating. Who will be better, TOF or structured light?
Software recommendation - office software
Intel plans to sell baseband chip business, but Apple has given up?
Multithreading (basic)
How to prevent XSS in PHP
Meeting OA project progress (I)
Enter a URL to this page to show it. What happened in this process?
[machine learning basics] - another perspective to explain SVM
JUC源码学习笔记3——AQS等待队列和CyclicBarrier,BlockingQueue
EF combined with sqlbulkcopy batch insert data
1024 happy holidays
hping3安装使用
EMQ Yingyun technology was listed on the 2022 "cutting edge 100" list of Chinese entrepreneurs
Envi SHP to ROI and mask the grid
MySQL basic commands
Causes and solutions of QT signal and slot connection failure
Codeforces round 690 (Div. 3) B. last year's substring conventional solution
Hping3 installation and use
Sword finger offer 22. the penultimate node in the linked list
Codeforces round 690 (Div. 3) C. unique number conventional solution