mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-25 05:22:39 +08:00
style: enable NeedBraces
in checkstyle (#5227)
* enable style NeedBraces * style: enable NeedBraces in checkstyle --------- Co-authored-by: Samuel Facchinello <samuel.facchinello@piksel.com>
This commit is contained in:

committed by
GitHub

parent
51fcc66345
commit
87b17e0571
@ -16,20 +16,21 @@ final class LongestNonRepeativeSubstring {
|
||||
char temp = s.charAt(i);
|
||||
|
||||
// adding key to map if not present
|
||||
if (!map.containsKey(temp)) map.put(temp, 0);
|
||||
// checking if the first value is the dublicate value
|
||||
else if (s.charAt(start) == temp)
|
||||
if (!map.containsKey(temp)) {
|
||||
map.put(temp, 0);
|
||||
} else if (s.charAt(start) == temp) {
|
||||
start++;
|
||||
// checking if the previous value is dublicate value
|
||||
else if (s.charAt(i - 1) == temp) {
|
||||
if (max < map.size()) max = map.size();
|
||||
} else if (s.charAt(i - 1) == temp) {
|
||||
if (max < map.size()) {
|
||||
max = map.size();
|
||||
}
|
||||
map = new HashMap<>();
|
||||
start = i;
|
||||
i--;
|
||||
}
|
||||
// last possible place where dublicate value can be is between start and i
|
||||
else {
|
||||
if (max < map.size()) max = map.size();
|
||||
} else {
|
||||
if (max < map.size()) {
|
||||
max = map.size();
|
||||
}
|
||||
while (s.charAt(start) != temp) {
|
||||
map.remove(s.charAt(start));
|
||||
start++;
|
||||
@ -39,7 +40,9 @@ final class LongestNonRepeativeSubstring {
|
||||
|
||||
i++;
|
||||
}
|
||||
if (max < map.size()) max = map.size();
|
||||
if (max < map.size()) {
|
||||
max = map.size();
|
||||
}
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user