5840. Minimum Number of Swaps to Make the String Balanced
5840. Minimum Number of Swaps to Make the String Balanced
tag: stack, greedy
Description
Solution
In each switch, brackets are reduced mostly 2, at least 1.
1 | //Just swap the first dismatched ] with second dismatched [ |
Code
1 | class Solution { |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.