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