Leetcode PHP题解--D140 58. Length of Last Word
D140 58. Length of Last Word
题目链接
题目分析
给定一个字符串,返回最后一个出现的单词长度。
解题思路
遍历字符串,当遇到一个字符,其前一个字符是空格时才能重新计数。
最终代码
<?php
class Solution {
/**
* @param String $s
* @return Integer
*/
function lengthOfLastWord($s) {
$len = 0;
if($s == ''){
return $len;
}
$str = str_split($s);
$prev = NULL;
foreach($str as $char){
if($char != ' '){
if($prev == ' '){
$len = 0;
}
$len++;
}
$prev = $char;
}
return $len;
}
}
若觉得本文章对你有用,欢迎用爱发电资助。
1 Comment
大臺灣舒舒茶莊 +籟wsww23或加賴c8672舒壓按摩/個人/油壓/五花八門/汽車旅館找小姐/叫小姐/外送茶喝茶流程/老司機交你怎麼喝茶telegram:wsww23【加我有驚喜】 #學生妹#模特#OL#清純 #美腿#高挑#外約無套內射熟女媽媽#服務技術好熟女媽媽#口爆重口味熟女媽媽#粉紅色奶頭# +賴wsww23或加賴c8672吞精#粉色嫩穴#奶泡#69#顏射#老漢推車#觀音坐蓮#無套白虎學生妹+籟wsww23或加賴c8672#無套爆乳性感人妻telegram:wsww23【加我有驚喜】 #外約無套內射熟女媽媽 +賴wsww23或加賴c8672#服務技術好熟女媽媽#口爆重口味熟女媽媽 #火車便當#蘿莉類型+籟wsww23或加賴c8672#空姐兼職#第一次下海#試車#F奶#G奶#超大奶#童顏巨乳#性感模特#清純學生#童顏巨乳#老熟女#人妻#奶水媽媽telegram:wsww23【加我有驚喜】#YT網紅#主播網紅#空姐# +賴wsww23或加賴c8672混血兒#高挑美腿#住家#旅館#車站找小姐加#台北#新北#新竹#高雄#台南#台中#彰化外約#口交#口爆#肛交#BJ中出telegram:wsww23【加我有驚喜】#內射#後門#奶水媽媽#無套BJ#求助單親媽媽#處女 +賴wsww23或加賴c8672 賴wsww23 或賴c8672 《telegram:wsww23》telegram全臺本土正妹頻道:https://t.me/wmw588 台北外約+籟wsww23或加賴c8672學生妹台大學生妹 #輔仁學生妹 #淡江學生妹兼職外約台中外約學生妹/逢甲學生妹 #東海學生妹+籟wsww23或加賴c8672 #靜宜學生妹兼職外約台大學生妹 #輔仁學生妹 #淡江學生妹兼職外約/清華學生妹 賴wsww23 或賴c8672《telegramwsww23》#育達學生妹 #交通大學生兼職外約/台南學生妹 +籟wsww23或加賴c8672#樹德學生妹 #國立大學生兼職外約高雄外約學生妹 樹德學生妹 #守義學生妹逢甲學生妹 #東海學生妹 #靜宜學生妹兼職外約台大學生妹 #輔仁學生妹 賴wsww23 或賴c8672 《telegram:wsww23》#淡江學生妹兼職外約清華學生妹 #育達學生妹 #交通大學生兼職外約台南學生妹 #樹德學生妹 #國立大學生兼職外約樹德學生妹 #守義學生妹 #輔英學生妹兼職外約醫科學生妹 +籟wsww23或加賴c8672#守義學生妹 #樹德學生妹兼職外約爆乳無套妹肛交大奶妹#性感高桃氣質爆乳模特大奶賴wsww23 或賴c8672 《telegram:wsww23》 高雄外送茶叫小姐台中外送茶汽車旅館爆乳無套妹肛交大奶妹#性感高桃氣質爆乳模特大奶 高雄外送茶叫小姐台中外送茶汽車旅館彰化外送茶找小姐 賴wsww23 或賴c8672 《telegram:wsww23》台南火車站找小姐 叫小姐 高雄火車站找小姐telegram全臺本土正妹頻道:https://t.me/wmw588 賴wsww23 或賴c8672 《telegram:wsww23》telegram全臺本土正妹頻道:https://t.me/wmw588 台北外約+籟wsww23或加賴c8672學生妹台大學生妹 #輔仁學生妹 #淡江學生妹兼職外約台中外約學生妹/逢甲學生妹 #東海學生妹+籟wsww23或加賴c8672#靜宜學生妹兼職外約台大學生妹 #輔仁學生妹 #淡江學生妹兼職外約/清華學生妹 賴wsww23 或賴c8672或 《telegram:wsww23》 #育達學生妹 #交通大學生兼職外約/台南學生妹 #樹德學生妹 #國立大學生兼職外約高雄外約學生妹 樹德學生妹 #守義學生妹逢甲學生妹 #東海學生妹 #靜宜學生妹兼職外約台大學生妹 #輔仁學生妹 賴wsww23 或賴c8672 《telegram:wsww23》 #淡江學生妹兼職+籟wsww23或加賴c8672外約清華學生妹 #育達學生妹 #交通大學生兼職外約台南學生妹 #樹德學生妹 #國立大學生兼職+籟wsww23或加賴c8672外約樹德學生妹 #守義學生妹 #輔英學生妹兼職外約醫科學生妹 #守義學生妹 #樹德學生妹兼職外約 爆乳無套妹肛交大奶妹#性感高桃氣質爆乳模特大奶賴wsww23 或賴c8672 《telegram:wsww23》 高雄外送茶+籟wsww23或加賴c8672叫小姐台中外送茶汽車旅館 爆乳無套妹肛交大奶妹#+籟wsww23或加賴c8672性感高桃氣質爆乳模特大奶 高雄外送茶叫小姐台中外送茶汽車旅館彰化外送茶找小姐 賴wsww23 或賴c8672 《telegram:wsww23》 台南火車站找小姐 叫小姐 高雄火車站找小姐telegram全臺本土正妹頻道:https://t.me/wmw588 新竹+籟wsww23或加賴c8672外送茶叫大奶學生 單親奶水媽媽無套內射外送茶留言板小姐名單telegram全臺本土正妹頻道:https://t.me/wmw588 新竹外送茶+籟wsww23或加賴c8672叫大奶學生 單親奶水媽媽無套內射外送茶留言板小姐名單telegram全臺本土正妹頻道:https://t.me/wmw588