let quickSort = function(arr, i , j) {
    if (i < j) {
        let pivot = parition(arr, i, j);
        swap(arr, i, pivot);
        if (pivot > 0) {
            quickSort(arr, i, pivot);
            quickSort(arr, pivot+1, j);  
        } 
    }
}

var parition = function (arr, l , h ) {
    let pivot = arr[l];
    let i = l, j = h;
    while (i < j) {
        do {
            i++;
        } while (arr[i] <= pivot)
 
        do {
            j--;
        } while(arr[j] > pivot)
            
        if (i < j) {
          swap(arr, i , j);   
        }
    }    
    return j;
}

var swap = function (arr, i , j) {
    let temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
}
QuickSort
var longestPalindrome = function(s) {
    if (s === null || s.length < 1) '';
    let start = 0, end = 0;    
    for (let i = 0; i < s.length; i++) {
        let len1 = expandAroundCenter(s, i, i);
        let len2 = expandAroundCenter(s, i, i+1);
        let len = Math.max(len1, len2);
        if (len > (end-start)) {
            start = i - parseInt((len-1)/2);
            end = i + parseInt(len/2);
        }
    }    
    return s.substring(start, end+1);
}


var expandAroundCenter = function(s, left, right) {
    let l = left, r = right;
    while (l >=0 && r < s.length && s[l] === s[r]) {
        l--;
        r++;
    }
    return r-l-1;
}
Longest Palindromic SubString with expand center approach
var largestSubstring = function(s, s2) {
    let suffix = [[0]];
    let maxCount = 0;
    let max;
    for (let i =0; i < s.length; i++) {
        if (!suffix[i]) suffix[i] = [];
        for (let j = 0; j < s2.length; j++) {
            if (s[i] === s2[j]) {
                suffix[i][j] = (i > 0 ? (suffix[i-1][j-1] || 0) : 0) + 1;  
            }
            if (suffix[i][j] > maxCount) {
               maxCount = suffix[i][j];
               max = [i, j]; 
            }
        }
    }
    if (!max) {
        return s[0];
    }
    let string = '', i = max[0], j = max[1];
    while (i >= 0 && j >=0) {
        if (suffix[i][j] > 0) {
            string+=s[i];
        }
        i--;
        j--;
    }
    return string;
   
    
};
Longest SubString Using Suffix Table