Easy And Understable code in JAVA ----->


#1
    int count = 0 ; 
    int k = 0 ;
  
    for( int i = 0 ; i < A.length() ; i++ )
    {
        
        char ch = A.charAt(i) ;
        
        if( ch == '(')
        {
            count++ ;
        }
        else if( ch==')')
        {
            
            if( count ==  k )
            {
                k++ ;
                count= k ;
            }
           else{ 
            count-- ;
           }
        }
        
    }
    
    return count ;

#2

can you please tell me, how you come up with solution ?
@yuvrajbhati2507_192d