<commit_before>class Solution {
public:

    // if l == r, check if palindrome with odd # of letters
    // else check if palindrome with even # of letters
    string getPalindromeAtCenter(const string& s, int l, int r) {
        assert(l == r || l+1 == r);
        
        if (s[l] != s[r] || r >= s.size()) {
            return string("");
        }
        
        while (l >= 0 && r < s.size() && s[l] == s[r]) {
            l--;
            r++;
        }
        
        //when we exited loop, either we were out of bounds, or last thing didn't match
        //in either case, we need to fix up the indices
        l++;
        r--;
        return s.substr(l, r-l+1);
    }
    
    string longestPalindrome(string s) {
        string longest;
        for (int i=0; i<s.size(); i++) {
            //get palindrome substr centered at i
            string oddCand = getPalindromeAtCenter(s, i, i);
            if (oddCand.size() > longest.size()) {
                longest = oddCand;
            }
            
            //get palindrome substr centered between i and i+1
            string evenCand = getPalindromeAtCenter(s, i, i+1);
            if (evenCand.size() > longest.size()) {
                longest = evenCand;
            }
        }
        return longest;
    }
};

<commit_msg>Bug fix.<commit_after>class Solution {
public:

    // if l == r, check if palindrome with odd # of letters
    // else check if palindrome with even # of letters
    string getPalindromeAtCenter(const string& s, int l, int r) {
        assert(l == r || l+1 == r);
        
        if (r >= s.size() || s[l] != s[r]) {
            return string("");
        }
        
        while (l >= 0 && r < s.size() && s[l] == s[r]) {
            l--;
            r++;
        }
        
        //when we exited loop, either we were out of bounds, or last thing didn't match
        //in either case, we need to fix up the indices
        l++;
        r--;
        return s.substr(l, r-l+1);
    }
    
    string longestPalindrome(string s) {
        string longest;
        for (int i=0; i<s.size(); i++) {
            //get palindrome substr centered at i
            string oddCand = getPalindromeAtCenter(s, i, i);
            if (oddCand.size() > longest.size()) {
                longest = oddCand;
            }
            
            //get palindrome substr centered between i and i+1
            string evenCand = getPalindromeAtCenter(s, i, i+1);
            if (evenCand.size() > longest.size()) {
                longest = evenCand;
            }
        }
        return longest;
    }
};


{'fraction_non_alphanumeric': 0.12725874663590928, 'fraction_numerical': 0.00461361014994233, 'mean_word_length': 1.4249767008387697, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '210330', 'n_tokens_mistral': 795, 'n_tokens_neox': 774, 'n_words': 251}