File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 131
131
476|[ Number Complement] ( ./0476-number-complement.js ) |Easy|
132
132
500|[ Keyboard Row] ( ./0500-keyboard-row.js ) |Easy|
133
133
506|[ Relative Ranks] ( ./0506-relative-ranks.js ) |Easy|
134
+ 520|[ Detect Capital] ( ./0520-detect-capital.js ) |Easy|
134
135
541|[ Reverse String II] ( ./0541-reverse-string-ii.js ) |Easy|
135
136
542|[ 01 Matrix] ( ./0542-01-matrix.js ) |Medium|
136
137
551|[ Student Attendance Record I] ( ./0551-student-attendance-record-i.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 520. Detect Capital
3
+ * https://leetcode.com/problems/detect-capital/
4
+ * Difficulty: Easy
5
+ *
6
+ * We define the usage of capitals in a word to be right when one of the following
7
+ * cases holds:
8
+ * - All letters in this word are capitals, like "USA".
9
+ * - All letters in this word are not capitals, like "leetcode".
10
+ * - Only the first letter in this word is capital, like "Google".
11
+ *
12
+ * Given a string word, return true if the usage of capitals in it is right.
13
+ */
14
+
15
+ /**
16
+ * @param {string } word
17
+ * @return {boolean }
18
+ */
19
+ var detectCapitalUse = function ( word ) {
20
+ return / ^ [ A - Z ] ? [ a - z ] + $ | ^ [ A - Z ] + $ / . test ( word ) ;
21
+ } ;
You can’t perform that action at this time.
0 commit comments