refactor: fix typo in class name LongestNonRepetitiveSubstring
(#5359)
This commit is contained in:
parent
622a3bf795
commit
74b05ef7c2
@ -1,16 +1,17 @@
|
|||||||
package com.thealgorithms.strings;
|
package com.thealgorithms.strings;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
final class LongestNonRepeativeSubstring {
|
final class LongestNonRepetitiveSubstring {
|
||||||
private LongestNonRepeativeSubstring() {
|
private LongestNonRepetitiveSubstring() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int lengthOfLongestSubstring(String s) {
|
public static int lengthOfLongestSubstring(String s) {
|
||||||
int max = 0;
|
int max = 0;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
HashMap<Character, Integer> map = new HashMap<>();
|
Map<Character, Integer> map = new HashMap<>();
|
||||||
|
|
||||||
while (i < s.length()) {
|
while (i < s.length()) {
|
||||||
char temp = s.charAt(i);
|
char temp = s.charAt(i);
|
@ -3,13 +3,13 @@ package com.thealgorithms.strings;
|
|||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class LongestNonRepeativeSubstringTest {
|
public class LongestNonRepetitiveSubstringTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void palindrome() {
|
public void palindrome() {
|
||||||
String input1 = "HelloWorld";
|
String input1 = "HelloWorld";
|
||||||
String input2 = "javaIsAProgrammingLanguage";
|
String input2 = "javaIsAProgrammingLanguage";
|
||||||
Assertions.assertEquals(LongestNonRepeativeSubstring.lengthOfLongestSubstring(input1), 5);
|
Assertions.assertEquals(LongestNonRepetitiveSubstring.lengthOfLongestSubstring(input1), 5);
|
||||||
Assertions.assertEquals(LongestNonRepeativeSubstring.lengthOfLongestSubstring(input2), 9);
|
Assertions.assertEquals(LongestNonRepetitiveSubstring.lengthOfLongestSubstring(input2), 9);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user