Is using Regex considered as cheating?

  • 0
    public class Solution {
        public int lengthOfLastWord(String s) {
            String[] words = s.split("\\s+");
                return 0;
            return words[words.length-1].length();

    This looks too easy if Regex is allowed.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.