当前位置:网站首页>HJ1 string length of the last word
HJ1 string length of the last word
2022-08-07 14:02:00 【hash hip hop】
Description
Calculate the length of the last word of the string, the words are separated by spaces, and the length of the string is less than 5000.(Note: the end of the string does not end with a space)
Enter description:
Enter a line, representing the string to be calculated, non-empty, and the length is less than 5000.
Output description:
Outputs an integer representing the length of the last word of the input string.
Example 1
Enter:
hello nowcoder
Output:
8
Description:
The last word is nowcoder and the length is 8
Analysis
First cut the string according to spaces, and then calculate the length of the last item of the cut array
Code
const str = readline()const arr = str.split(' ')console.log(arr[arr.length - 1span>].length)边栏推荐
- C语言标准输入输出(11)
- Distributed pre-course: Redis implements distributed locks
- Lombok常用方法及原理介绍
- Network Foundation (3) 02-Basic Concept of Network - DNS server hosts file configuration & three-way handshake of website access process & BS architecture - browser access, CS architecture - installat
- Qt implementation based on matchtemplate long shots
- [Leetcode]21. 合并两个有序链表
- redis总结_原理
- Meta proposes OmniMAE: Pre-training video and text with a unified architecture
- LinkedList 底层学习
- [华为云在线课程][SQL语法分类][数据查询][学习笔记]
猜你喜欢

2022年流动式起重机司机试题模拟考试平台操作

mysql database source command to import sql file records

LeetCode high-frequency question: longest common subsequence, playing game A and game B, how many prizes can the two brothers get by adding up

Navicat连接mysql一段时间未操作之后卡住几秒

2022年危险化学品生产单位安全生产管理人员考试题模拟考试题库及答案

LOGO 8.3 Web Server功能
一个程序从编译到运行的全过程

MySQL:使用自定义函数计算经纬度之间的最短距离

室内定位之CSI指纹定位

DiskGenius Installation Tutorial
随机推荐
Developer Growth Incentive Program - Development Notes: The Simplest Steps to Transplant LVGL
helm安装报错Request entity too large: limit is 3145728
NestedTensor
下一代无线局域网-高吞吐率
Reason for MySQL error: ERROR 1241 (21000): Operand should contain 1 column(s)
内存管理(二)——内存分段
Is Founder Medium-Term Futures a regular futures company?Is it safe to open an account?
ENScanGo主域名批量提取脚本
Fiddler抓包原理讲解以及实例操作
Red team web management information collection
mysql database source command to import sql file records
Text-to-Image with Diffusion models的巅峰之作:深入解读 DALL·E 2
炒股用同花顺安全吗?资金会不会被转走?
CSO面对面|对话迷你世界,畅谈游戏行业的安全建设
@RequestMapping注解标识的位置
LeetCode_6142_统计坏数对的数目
蓝图传值给Niagara
开发者成长激励计划-开发笔记:最简步骤移植LVGL
室内定位之CSI指纹定位
内存管理(一)——内存分配