public static int lengthOfLastWord(String s) {
		if(s == null) {
			return 0;
		}
		
		char[] cs = s.toCharArray();
		
		int[][] flow = {
				{0, 1},
				{0, 1}
		};
		
		int len = 0;
		int state = 0;
		for(int i = 0; i < cs.length; i++) {
			char c = cs[i];
			
			int x = 0;
			if(c != ' ') {
				x = 1;
			}
			
			int nstate = flow[state][x];
			if(state == 0 && nstate == 1) {
				len = 0;
			} 
			
			if(nstate == 1) {
				len += 1;
			}
			state = nstate;
		}
		
		return len;
	}