-
Notifications
You must be signed in to change notification settings - Fork 20k
update BalancedBrackets #1029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update BalancedBrackets #1029
Conversation
@yanglbme Please review ^_^ |
* @return {@code true} if {@code leftBracket} and {@code rightBrackets} is paired, | ||
* otherwise {@code false} | ||
*/ | ||
public static boolean isPaired(char leftBracket, char rightBrackets) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be rightBracket
, not rightBrackets
:
/**
* Check if {@code leftBracket} and {@code rightBracket} is paired or not
*
* @param leftBracket left bracket
* @param rightBracket right bracket
* @return {@code true} if {@code leftBracket} and {@code rightBracket} is paired,
* otherwise {@code false}
*/
public static boolean isPaired(char leftBracket, char rightBracket) {
char[][] pairedBrackets = {
{'(', ')'},
{'[', ']'},
{'{', '}'},
{'<', '>'}
};
for (char[] pairedBracket : pairedBrackets) {
if (pairedBracket[0] == leftBracket && pairedBracket[1] == rightBracket) {
return true;
}
}
return false;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! Please review again! @yanglbme
*/ | ||
class BalancedBrackets { | ||
|
||
/** | ||
* Check if {@code leftBracket} and {@code rightBrackets} is paired or not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Check if {@code leftBracket} and {@code rightBrackets} is paired or not | |
* Check if {@code leftBracket} and {@code rightBracket} is paired or not |
* Check if {@code leftBracket} and {@code rightBrackets} is paired or not | ||
* | ||
* @param leftBracket left bracket | ||
* @param rightBrackets right bracket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param rightBrackets right bracket | |
* @param rightBracket right bracket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review again! Thanks
code reuse!