Skip to content

Commit 45778ae

Browse files
committed
Cheak Balanced String πŸ’š
0 parents  commit 45778ae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

β€ŽCheak Balanced String.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
bool isBalanced(string num)
4+
{
5+
map<int, int>mp;
6+
bool cheak = true;
7+
for(auto ch:num)
8+
{
9+
mp[cheak] += ch - '0';
10+
cheak = !cheak;
11+
}
12+
return mp[0] == mp[1];
13+
}
14+
};

0 commit comments

Comments
Β (0)