OpenGenus / cosmos

World's largest Contributor driven code dataset | Used in Quark Search Engine, @OpenGenus IQ, OpenGenus Visual Project

Home Page:http://internship.opengenus.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minimum swaps for bracket balancing

Op-panda opened this issue · comments

This is a(n):

  • New algorithm
  • Update to an existing algorithm
  • Error
  • Proposal to the Repository

Details:

Greedy Algorithm:
You are given a string of 2N characters consisting of N ‘[‘ brackets and N ‘]’ brackets. A string is considered balanced if it can be represented in the for S2[S1] where S1 and S2 are balanced strings. We can make an unbalanced string balanced by swapping adjacent characters. Calculate the minimum number of swaps necessary to make a string balanced.

@AdiChat please assign me this issue. I am a participant of Hacktoberfest.