Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b43b927

Browse files
committed
Add solution #2124
1 parent 3580cdc commit b43b927

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,761 LeetCode solutions in JavaScript
1+
# 1,762 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1626,6 +1626,7 @@
16261626
2120|[Execution of All Suffix Instructions Staying in a Grid](./solutions/2120-execution-of-all-suffix-instructions-staying-in-a-grid.js)|Medium|
16271627
2121|[Intervals Between Identical Elements](./solutions/2121-intervals-between-identical-elements.js)|Medium|
16281628
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|
16291630
2127|[Maximum Employees to Be Invited to a Meeting](./solutions/2127-maximum-employees-to-be-invited-to-a-meeting.js)|Hard|
16301631
2129|[Capitalize the Title](./solutions/2129-capitalize-the-title.js)|Easy|
16311632
2130|[Maximum Twin Sum of a Linked List](./solutions/2130-maximum-twin-sum-of-a-linked-list.js)|Medium|
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
};

0 commit comments

Comments
 (0)