leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1963.cpp (273B)
0 class Solution { 1 public: 2 int minSwaps(const string &s) { 3 int size = 0; 4 for (const char c : s) { 5 if (c == '[') 6 size++; 7 else if (size > 0) 8 size--; 9 } 10 return (size + 1) / 2; 11 } 12 };