Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defined as a character sequence consists of non-space cha…
1.题目: Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". 运用到了栈的思想.先进后出,这样就逆序了. 时间复杂度,就是整个程序在运行过程中,每个小模块运行的次数之和. 时间复杂度指运行时间需求,空间复杂度是指运行空间需求. public class toChar1{ pu…
题目:编写一个方法,返回字符串中最小长度的单词的长度. var str = 'What a good day today!'; 1 //方法一 2 function returnString1(str){ 3 var arr = str.split(' '); 4 var num = []; 5 // console.log(arr); 6 for(var i=0,len=arr.length; i<len; i++){ 7 // console.log(arr[i].length); 8 nu…