File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,761 LeetCode solutions in JavaScript
1
+ # 1,762 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1626
1626
2120|[ Execution of All Suffix Instructions Staying in a Grid] ( ./solutions/2120-execution-of-all-suffix-instructions-staying-in-a-grid.js ) |Medium|
1627
1627
2121|[ Intervals Between Identical Elements] ( ./solutions/2121-intervals-between-identical-elements.js ) |Medium|
1628
1628
2122|[ Recover the Original Array] ( ./solutions/2122-recover-the-original-array.js ) |Hard|
1629
+ 2124|[ Check if All A's Appears Before All B's] ( ./solutions/2124-check-if-all-as-appears-before-all-bs.js ) |Easy|
1629
1630
2127|[ Maximum Employees to Be Invited to a Meeting] ( ./solutions/2127-maximum-employees-to-be-invited-to-a-meeting.js ) |Hard|
1630
1631
2129|[ Capitalize the Title] ( ./solutions/2129-capitalize-the-title.js ) |Easy|
1631
1632
2130|[ Maximum Twin Sum of a Linked List] ( ./solutions/2130-maximum-twin-sum-of-a-linked-list.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2124. Check if All A's Appears Before All B's
3
+ * https://leetcode.com/problems/check-if-all-as-appears-before-all-bs/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears
7
+ * before every 'b' in the string. Otherwise, return false.
8
+ */
9
+
10
+ /**
11
+ * @param {string } s
12
+ * @return {boolean }
13
+ */
14
+ var checkString = function ( s ) {
15
+ let seen = false ;
16
+
17
+ for ( const char of s ) {
18
+ if ( char === 'b' ) seen = true ;
19
+ else if ( seen ) return false ;
20
+ }
21
+
22
+ return true ;
23
+ } ;
You can’t perform that action at this time.
0 commit comments