human
Check if expression contains redundant bracket or not | Set 2 | Function to check for redundant braces.
count of no of signs.
Driver Code"
Solution in Python:
assistant
#Here is code to check if expression contains redundant bracket or not and the other steps required.
 def IsRedundantBraces ( A ) :
	a , b = 0 , 0 ;
	for i in range ( len ( A ) ) :
		if ( A [ i ] == ' ( ' and A [ i + 2 ] == ' ) ' ) :
			return True ;
		if ( A [ i ] == ' * ' or A [ i ] == ' + ' or A [ i ] == ' - ' or A [ i ] == ' / ' ) :
			a += 1 ;
		if ( A [ i ] == ' ( ' ) :
			b += 1 ;
	if ( b > a ) :
		return True ;
	return False ;
if __name__ == ' _ _ main _ _ ' :
	A = " ( ( ( a + b ) ▁ + ▁ c ) ▁ + ▁ d ) " ;
	if ( IsRedundantBraces ( A ) ) :
		print ( " YES " ) ;
	else :
		print ( " NO " ) ;