We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d9ceb4b commit 4c0c2daCopy full SHA for 4c0c2da
August Challenge/com/leetcode/AugustChallenge/week1/DetectCapital.java
@@ -0,0 +1,27 @@
1
+package com.leetcode.AugustChallenge.week1;
2
+
3
+public class DetectCapital {
4
5
+ public boolean detectCapitalUse(String word) {
6
+ int n = word.length();
7
+ if (n == 1)
8
+ return true;
9
10
+ if (Character.isUpperCase(word.charAt(0)) && Character.isUpperCase(word.charAt(1))) {
11
+ for (int i = 2; i < n; i++) {
12
+ if (Character.isLowerCase(word.charAt(i)))
13
+ return false;
14
+ }
15
+ } else {
16
+ for (int i = 1; i < n; i++) {
17
+ if (Character.isUpperCase(word.charAt(i)))
18
19
20
21
22
23
24
+ public boolean detectCapitalUseUsingRegex(String word) {
25
+ return word.matches("[A-Z]*|.[a-z]*");
26
27
+}
0 commit comments