Skip to content

Instantly share code, notes, and snippets.

View agchou's full-sized avatar

Aaron Chou agchou

  • Instacart
  • San Francisco, CA
View GitHub Profile
@agchou
agchou / longestPalindrome
Last active August 29, 2015 14:01
Linear-ish time solution for finding longest palindrome in string.
var longestPalindrome = function (string) {
var current, i, isPalindrome, j, longest;
longest = current = '';
for (i = string.length - 2; i >= 0; i--) {
j = 1;
do {
// check for odd palindrome