mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-22 19:59:09 +08:00
style: enable LocalVariableName
in CheckStyle (#5191)
* style: enable LocalVariableName in checkstyle * Removed minor bug * Resolved Method Name Bug * Changed names according to suggestions
This commit is contained in:
@ -33,24 +33,24 @@ public final class PalindromicPartitioning {
|
||||
|
||||
int i;
|
||||
int j;
|
||||
int L; // different looping variables
|
||||
int subLen; // different looping variables
|
||||
|
||||
// Every substring of length 1 is a palindrome
|
||||
for (i = 0; i < len; i++) {
|
||||
isPalindrome[i][i] = true;
|
||||
}
|
||||
|
||||
/* L is substring length. Build the solution in bottom up manner by considering all
|
||||
/* subLen is substring length. Build the solution in bottom up manner by considering all
|
||||
* substrings of length starting from 2 to n. */
|
||||
for (L = 2; L <= len; L++) {
|
||||
// For substring of length L, set different possible starting indexes
|
||||
for (i = 0; i < len - L + 1; i++) {
|
||||
j = i + L - 1; // Ending index
|
||||
// If L is 2, then we just need to
|
||||
for (subLen = 2; subLen <= len; subLen++) {
|
||||
// For substring of length subLen, set different possible starting indexes
|
||||
for (i = 0; i < len - subLen + 1; i++) {
|
||||
j = i + subLen - 1; // Ending index
|
||||
// If subLen is 2, then we just need to
|
||||
// compare two characters. Else need to
|
||||
// check two corner characters and value
|
||||
// of P[i+1][j-1]
|
||||
if (L == 2) {
|
||||
if (subLen == 2) {
|
||||
isPalindrome[i][j] = (word.charAt(i) == word.charAt(j));
|
||||
} else {
|
||||
isPalindrome[i][j] = (word.charAt(i) == word.charAt(j)) && isPalindrome[i + 1][j - 1];
|
||||
|
Reference in New Issue
Block a user