Skip to content

Commit

Permalink
뒤집기
Browse files Browse the repository at this point in the history
  • Loading branch information
yewon-yw authored Jun 1, 2022
1 parent 17b58d0 commit 0843e87
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions greedy_algorithm/1439.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
cin >> str;
int zcnt = 0, ocnt = 0;
if (str[0] == '0') zcnt++;
else ocnt++;
for (int i = 1; i < str.size(); i++) {
if (str[i] != str[i - 1]) {
if (str[i] == '0') zcnt++;
else ocnt++;
}
}
cout << (zcnt < ocnt ? zcnt : ocnt) << "\n";
}

0 comments on commit 0843e87

Please sign in to comment.