Minimum number of swaps to make balanced parenthesis | Google | Meta

Minimum number of swap to make balanced parenthesis. It is not necessary to swap the adjacent elements. Otherwise if not possible return -1.

Example:

1. )()(  ----> 1, swap first and last parenthesis. 
2. ())  -----> -1, can not swap
3.  (()()) -----> -1
4.  (()))( ------ 1,s swap last two parenthesis
public int minimumNoSwap(String s){
	return -1;
}
Comments (2)