function GetLongestSubstring(str) {
const size = str.length;
let start = 0;
let end = 0;
let max = 0;
for (let i = 0; i < size - 1; i++) {
for (let j = i + 1; j < size; j++) {
if (str[i] == str[j]) {
let temp = Math.abs(j - i - 1);
if (temp > max) {
max = temp;
start = i + 1;
end = j;
}
}
}
}
return str.substring(start, end);
}
const str = "zXoDnodejsDekq";
console.log(GetLongestSubstring(str));
/*
run:
nodejs
*/