MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / Leetcode58

Class Leetcode58

Java/Leetcode/Leetcode58.java:3–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1package com.company;
2
3public class Leetcode58 {
4 public static void main(String[] args) {
5 String s=" fly me to the moon ";
6 System.out.println(length(s));
7 }
8
9 static int length(String str){
10 StringBuilder s=new StringBuilder(str.trim());
11 int l=0;
12 for (int i = s.length()-1; i >=0 ; i--) {
13 if(Character.isWhitespace(s.charAt(i))){
14 return l=(s.substring(i+1).length());
15 }
16 }
17 return s.length();
18 }
19}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected