NeetCode #116LC-1963MediumArrays & Hashing
← Back to All Problems

#116 · #1963 · Minimum Number of Swaps to Make the String Balanced(使字符串平衡的最少交换次数)

📌 Problem Statement & Constraints

Given a 0-indexed string s of even length consisting of [ and ], return the minimum number of swaps (of any two indices) needed to make it balanced. Constraints: 1 <= s.length <= 10^5.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!