Unknown's avatar

2114. Maximum Number of Words Found in Sentences

2114. Maximum Number of Words Found in Sentences

class Solution {
    public int mostWordsFound(String[] sentences) {
        int max = Integer.MIN_VALUE;
        for(int i = 0; i < sentences.length; i++){
            max = Math.max(max, sentences[i].split(" ").length);
        }
        return max;
    }
}

Leave a comment