We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd4f143 commit 124bc46Copy full SHA for 124bc46
javascript/1189-maximum-number-of-balloons.js
@@ -4,9 +4,13 @@
4
var maxNumberOfBalloons = function(text) {
5
6
const balloonCach = {};
7
+ const ballonSet = new Set();
8
+ for(let i = 0; i < text.length; i++) {
9
+ ballonSet.add(text[i]);
10
+ }
11
12
for(let i = 0; i < text.length; i++) {
- if('balloon'.includes(text[i])) {
13
+ if(ballonSet.has(text[i])) {
14
if(balloonCach[text[i]]) {
15
balloonCach[text[i]] += 1;
16
} else {
0 commit comments