Minimum Length Word
this is test string
is
public class Solution {
public static String minLengthWord(String input){
String[] arr=input.split(" ");
int i=0;
int minlength;
minlength=Integer.MAX_VALUE;
String smallest;
smallest = "";
for(i=0;i<arr.length;i++)
{
if(arr[i].length() < minlength)
{
smallest=arr[i];
minlength=arr[i].length();
}
}
return smallest;
}
}
Comments
Post a Comment