Regex for sol 1 against rules? Or not?


  • 0
    G

    Hey all, this week was my first time trying the contest, and was looking at some top solutions and noticed that almost nobody used regex, is this against the rules?


  • 0

    @georgeqwu Hi, as long as it's not explicitly stated in the problem description, you can use whatever that's allowed, including regex.


  • 0
    G

    @1337c0d3r Thanks!

    This was my regex solution in case anyone's reading (sorry posted it in the wrong subtopic, it was before the subtopics were created ;) )

    public static boolean detectCapitalUse(String word) {
            return word.matches("[A-Z]*") || word.matches("[A-Z][a-z]*") || word.matches("[a-z]*");
    }
    

Log in to reply
 

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