<commit_before>package com.lutaoact;

import java.util.HashMap;

public class Solution {
    public String longestPalindrome(String s) {
        int length = s.length();
        if (length == 0) return "";

        char[] chars = s.toCharArray();
        boolean[][] flags = new boolean[length][length];
        for (int i = 0; i < length; i++) {
            for (int j = length - 1; j >= i; j--) {
                flags[i][j] = true;
                for (int m = i, n = j; m <= n; m++, n--) {
                    if (chars[m] != chars[n]) {
                        flags[i][j] = false;
                        break;
                    }
                }
            }
        }
        int maxLength = 0;
        int beginIndex = 0;
        int endIndex = 0;
        for (int i = 0; i < length; i++) {
            for (int j = 0; j < length; j++) {
                if (flags[i][j] && j - i + 1 > maxLength) {
                    maxLength = j - i + 1;
                    beginIndex = i;
                    endIndex = j + 1;
                }
            }
        }
        return s.substring(beginIndex, endIndex);
    }

    public int lengthOfLongestSubstring(String s) {
        int maxLength = 0;
        int start = 0;
        boolean[] flags = new boolean[256];
        char[] chars = s.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            char current = chars[i];
            if (flags[current]) {
                maxLength = Math.max(i - start, maxLength);
                for (int k = start; k < i; k++) {
                    if (chars[k] == current) {
                        start = k + 1;
                        break;
                    }
                    flags[chars[k]] = false;
                }
            } else {
                flags[current] = true;<commit_msg>longestPalindrome: optimization<commit_after>package com.lutaoact;

import java.util.HashMap;

public class Solution {
    public String longestPalindrome(String s) {
        int length = s.length();
        if (length == 0) return "";

        char[] chars = s.toCharArray();
        boolean[][] flags = new boolean[length][length];
        for (int i = 0; i < length; i++) {
            for (int j = length - 1; j >= i; j--) {
                flags[i][j] = true;
                for (int m = i, n = j; m <= n; m++, n--) {
                    if (chars[m] != chars[n]) {
                        flags[i][j] = false;
                        break;
                    }
                }
            }
        }
        int maxLength = 0;
        int beginIndex = 0;
        int endIndex = 0;
        for (int i = 0; i < length; i++) {
            for (int j = i; j < length; j++) {
                if (flags[i][j] && j - i + 1 > maxLength) {
                    maxLength = j - i + 1;
                    beginIndex = i;
                    endIndex = j + 1;
                }
            }
        }
        return s.substring(beginIndex, endIndex);
    }

    public int lengthOfLongestSubstring(String s) {
        int maxLength = 0;
        int start = 0;
        boolean[] flags = new boolean[256];
        char[] chars = s.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            char current = chars[i];
            if (flags[current]) {
                maxLength = Math.max(i - start, maxLength);
                for (int k = start; k < i; k++) {
                    if (chars[k] == current) {
                        start = k + 1;
                        break;
                    }
                    flags[chars[k]] = false;
                }
            } else {
                flags[current] = true;
{'fraction_non_alphanumeric': 0.12937636761487964, 'fraction_numerical': 0.009573304157549234, 'mean_word_length': 1.0778409090909091, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, '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': '6694782', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1013, 'n_words': 302}