def minCut_TLE2(self, s):
        if not s:
            return 0

        length = len(s)
        # palindrome dp
        dp2 = [[False for _ in xrange(length+1)] for _ in xrange(length+1)]
        for i in xrange(length+1):
            try:
                dp2[i][i] = True
                dp2[i][i+1] = True
            except IndexError:
                pass

        for i in xrange(length, -1, -1):
            for j in xrange(i+2, length+1):
                try:
                    dp2[i][j] = dp2[i+1][j-1] and s[i] == s[j-1]
                except IndexError:
                    dp2[i][j] = True


        # min cut dp
        dp = [[1<<32-1 for _ in xrange(length+1)] for _ in xrange(length+1)]
        for i in xrange(length+1):
            try:
                dp[i][i] = 0
                dp[i][i+1] = 0
            except IndexError:
                pass

        for i in xrange(length, -1, -1):
            for k in xrange(i, length+1):
                if dp2[i][k]:
                    dp[i][k] = 0
                else:
                    dp[i][k] = min(1+dp[i][j]+dp[j][k] for j in xrange(i+1, k))

        return dp[0][length]
Generate header for the token.
dataset/ETHPy150Open algorhythms/LeetCode/132 Palindrome Partitioning II.py/Solution.minCut_TLE2--crossover with--dataset/ETHPy150Open Relrin/aiorest-ws/aiorest_ws/auth/token/managers.py/JSONWebTokenManager._generate_header