Longest palindromes in a string

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
3
down vote

favorite
1












Honestly, I'm doing a practice and get blocked. Problem link.



The problem is simple, given a string, calculate the number of max length palindromes (Any substring is valid, which means you can take any chars you want and reorder them as you want). Return the result modulo 1000000007.



For example, given amim, the answer is 2 (mim and mam).



Full Code



#!/bin/python3

import math
import os
import random
import re
import sys
from itertools import permutations
from functools import lru_cache

# Complete the initialize function below.
def initialize(s):
# This function is called once before all queries.
s = [ord(i) - 97 for i in s]
results = [[0] * 26]
for i, v in enumerate(s):
result = results[i].copy()
result[v] += 1
results.append(result)
return results

def count(s):
result = [0] * 26
for i in s:
result[i] += 1
return result

factorial = lru_cache(None)(math.factorial)

p = 1000000007

pow = lru_cache(None)(pow)

# Complete the answerQuery function below.
def answerQuery(l, r):
# Return the answer for this query modulo 1000000007.
counted1 = counted_list[l - 1]
counted2 = counted_list[r]
counted = [counted2[i] - counted1[i] for i in range(26)]
left = 0
total = 0
divide =
for temp in counted:
left += temp & 1
total += temp >> 1
divide.append(temp >> 1)
total = factorial(total)
total = total % p
for i in divide:
temp = factorial(i)
temp = pow(temp, p - 2, p)
total = total * temp
result = total * (left or 1)
return result % p


if __name__ == '__main__':
s = input()

counted_list = initialize(s)
q = int(input())

for q_itr in range(q):
lr = input().split()

l = int(lr[0])

r = int(lr[1])

result = answerQuery(l, r)

print(result)


The code above can pass #0~#21 testcases and will fail in #22 due to timeout. (Just copy it to Problem link page given at the top)



As #22 testcase is very huge, I cannot post it here. So here is the link:



https://files.fm/u/mekwpf8u



If I can use numpy to rewrite this function, I think it will be better. But I cannot, I can only use the standard libs.



update



I use another customized factorial function but exceed memory usage limitation :/ But it really reduces the total time cost.



factorial_table = [1, 1]
def factorial(n):
if n < len(factorial_table):
return factorial_table[n]

last = len(factorial_table) - 1
total = factorial_table[last]
for i in range(last + 1, n + 1):
total *= i
factorial_table.append(total)

return total






share|improve this question





















  • Welcome to Code Review. Asking for advice on code yet to be written or implemented is off-topic for this site. See What topics can I ask about? for reference. Once you have written working code, you're welcome to ask a new question here and we can then help you improve it!
    – Phrancis
    Jun 27 at 6:02










  • @Phrancis Um... I don't understand what you mean? I have read your link and I think I am asking a question about best practice? The snippet given in my question is definitely a worked one, but it cost too much time. I want to know which part can be optimized.
    – Sraw
    Jun 27 at 6:14






  • 1




    @Phrancis I think this is a performance related issue, hence why I'm not voting to close.
    – Daniel
    Jun 27 at 6:29










  • @Sraw This is a really interesting problem. Can you update your question containing your full code (ie, initialize func, and main), with sample input/output. So others can better understand what it is supposed to do.
    – Ludisposed
    Jun 27 at 8:28










  • @Ludisposed OK, wait a minute.
    – Sraw
    Jun 27 at 8:40
















up vote
3
down vote

favorite
1












Honestly, I'm doing a practice and get blocked. Problem link.



The problem is simple, given a string, calculate the number of max length palindromes (Any substring is valid, which means you can take any chars you want and reorder them as you want). Return the result modulo 1000000007.



For example, given amim, the answer is 2 (mim and mam).



Full Code



#!/bin/python3

import math
import os
import random
import re
import sys
from itertools import permutations
from functools import lru_cache

# Complete the initialize function below.
def initialize(s):
# This function is called once before all queries.
s = [ord(i) - 97 for i in s]
results = [[0] * 26]
for i, v in enumerate(s):
result = results[i].copy()
result[v] += 1
results.append(result)
return results

def count(s):
result = [0] * 26
for i in s:
result[i] += 1
return result

factorial = lru_cache(None)(math.factorial)

p = 1000000007

pow = lru_cache(None)(pow)

# Complete the answerQuery function below.
def answerQuery(l, r):
# Return the answer for this query modulo 1000000007.
counted1 = counted_list[l - 1]
counted2 = counted_list[r]
counted = [counted2[i] - counted1[i] for i in range(26)]
left = 0
total = 0
divide =
for temp in counted:
left += temp & 1
total += temp >> 1
divide.append(temp >> 1)
total = factorial(total)
total = total % p
for i in divide:
temp = factorial(i)
temp = pow(temp, p - 2, p)
total = total * temp
result = total * (left or 1)
return result % p


if __name__ == '__main__':
s = input()

counted_list = initialize(s)
q = int(input())

for q_itr in range(q):
lr = input().split()

l = int(lr[0])

r = int(lr[1])

result = answerQuery(l, r)

print(result)


The code above can pass #0~#21 testcases and will fail in #22 due to timeout. (Just copy it to Problem link page given at the top)



As #22 testcase is very huge, I cannot post it here. So here is the link:



https://files.fm/u/mekwpf8u



If I can use numpy to rewrite this function, I think it will be better. But I cannot, I can only use the standard libs.



update



I use another customized factorial function but exceed memory usage limitation :/ But it really reduces the total time cost.



factorial_table = [1, 1]
def factorial(n):
if n < len(factorial_table):
return factorial_table[n]

last = len(factorial_table) - 1
total = factorial_table[last]
for i in range(last + 1, n + 1):
total *= i
factorial_table.append(total)

return total






share|improve this question





















  • Welcome to Code Review. Asking for advice on code yet to be written or implemented is off-topic for this site. See What topics can I ask about? for reference. Once you have written working code, you're welcome to ask a new question here and we can then help you improve it!
    – Phrancis
    Jun 27 at 6:02










  • @Phrancis Um... I don't understand what you mean? I have read your link and I think I am asking a question about best practice? The snippet given in my question is definitely a worked one, but it cost too much time. I want to know which part can be optimized.
    – Sraw
    Jun 27 at 6:14






  • 1




    @Phrancis I think this is a performance related issue, hence why I'm not voting to close.
    – Daniel
    Jun 27 at 6:29










  • @Sraw This is a really interesting problem. Can you update your question containing your full code (ie, initialize func, and main), with sample input/output. So others can better understand what it is supposed to do.
    – Ludisposed
    Jun 27 at 8:28










  • @Ludisposed OK, wait a minute.
    – Sraw
    Jun 27 at 8:40












up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





Honestly, I'm doing a practice and get blocked. Problem link.



The problem is simple, given a string, calculate the number of max length palindromes (Any substring is valid, which means you can take any chars you want and reorder them as you want). Return the result modulo 1000000007.



For example, given amim, the answer is 2 (mim and mam).



Full Code



#!/bin/python3

import math
import os
import random
import re
import sys
from itertools import permutations
from functools import lru_cache

# Complete the initialize function below.
def initialize(s):
# This function is called once before all queries.
s = [ord(i) - 97 for i in s]
results = [[0] * 26]
for i, v in enumerate(s):
result = results[i].copy()
result[v] += 1
results.append(result)
return results

def count(s):
result = [0] * 26
for i in s:
result[i] += 1
return result

factorial = lru_cache(None)(math.factorial)

p = 1000000007

pow = lru_cache(None)(pow)

# Complete the answerQuery function below.
def answerQuery(l, r):
# Return the answer for this query modulo 1000000007.
counted1 = counted_list[l - 1]
counted2 = counted_list[r]
counted = [counted2[i] - counted1[i] for i in range(26)]
left = 0
total = 0
divide =
for temp in counted:
left += temp & 1
total += temp >> 1
divide.append(temp >> 1)
total = factorial(total)
total = total % p
for i in divide:
temp = factorial(i)
temp = pow(temp, p - 2, p)
total = total * temp
result = total * (left or 1)
return result % p


if __name__ == '__main__':
s = input()

counted_list = initialize(s)
q = int(input())

for q_itr in range(q):
lr = input().split()

l = int(lr[0])

r = int(lr[1])

result = answerQuery(l, r)

print(result)


The code above can pass #0~#21 testcases and will fail in #22 due to timeout. (Just copy it to Problem link page given at the top)



As #22 testcase is very huge, I cannot post it here. So here is the link:



https://files.fm/u/mekwpf8u



If I can use numpy to rewrite this function, I think it will be better. But I cannot, I can only use the standard libs.



update



I use another customized factorial function but exceed memory usage limitation :/ But it really reduces the total time cost.



factorial_table = [1, 1]
def factorial(n):
if n < len(factorial_table):
return factorial_table[n]

last = len(factorial_table) - 1
total = factorial_table[last]
for i in range(last + 1, n + 1):
total *= i
factorial_table.append(total)

return total






share|improve this question













Honestly, I'm doing a practice and get blocked. Problem link.



The problem is simple, given a string, calculate the number of max length palindromes (Any substring is valid, which means you can take any chars you want and reorder them as you want). Return the result modulo 1000000007.



For example, given amim, the answer is 2 (mim and mam).



Full Code



#!/bin/python3

import math
import os
import random
import re
import sys
from itertools import permutations
from functools import lru_cache

# Complete the initialize function below.
def initialize(s):
# This function is called once before all queries.
s = [ord(i) - 97 for i in s]
results = [[0] * 26]
for i, v in enumerate(s):
result = results[i].copy()
result[v] += 1
results.append(result)
return results

def count(s):
result = [0] * 26
for i in s:
result[i] += 1
return result

factorial = lru_cache(None)(math.factorial)

p = 1000000007

pow = lru_cache(None)(pow)

# Complete the answerQuery function below.
def answerQuery(l, r):
# Return the answer for this query modulo 1000000007.
counted1 = counted_list[l - 1]
counted2 = counted_list[r]
counted = [counted2[i] - counted1[i] for i in range(26)]
left = 0
total = 0
divide =
for temp in counted:
left += temp & 1
total += temp >> 1
divide.append(temp >> 1)
total = factorial(total)
total = total % p
for i in divide:
temp = factorial(i)
temp = pow(temp, p - 2, p)
total = total * temp
result = total * (left or 1)
return result % p


if __name__ == '__main__':
s = input()

counted_list = initialize(s)
q = int(input())

for q_itr in range(q):
lr = input().split()

l = int(lr[0])

r = int(lr[1])

result = answerQuery(l, r)

print(result)


The code above can pass #0~#21 testcases and will fail in #22 due to timeout. (Just copy it to Problem link page given at the top)



As #22 testcase is very huge, I cannot post it here. So here is the link:



https://files.fm/u/mekwpf8u



If I can use numpy to rewrite this function, I think it will be better. But I cannot, I can only use the standard libs.



update



I use another customized factorial function but exceed memory usage limitation :/ But it really reduces the total time cost.



factorial_table = [1, 1]
def factorial(n):
if n < len(factorial_table):
return factorial_table[n]

last = len(factorial_table) - 1
total = factorial_table[last]
for i in range(last + 1, n + 1):
total *= i
factorial_table.append(total)

return total








share|improve this question












share|improve this question




share|improve this question








edited Jun 27 at 9:17









Ludisposed

5,68621656




5,68621656









asked Jun 27 at 5:37









Sraw

1184




1184











  • Welcome to Code Review. Asking for advice on code yet to be written or implemented is off-topic for this site. See What topics can I ask about? for reference. Once you have written working code, you're welcome to ask a new question here and we can then help you improve it!
    – Phrancis
    Jun 27 at 6:02










  • @Phrancis Um... I don't understand what you mean? I have read your link and I think I am asking a question about best practice? The snippet given in my question is definitely a worked one, but it cost too much time. I want to know which part can be optimized.
    – Sraw
    Jun 27 at 6:14






  • 1




    @Phrancis I think this is a performance related issue, hence why I'm not voting to close.
    – Daniel
    Jun 27 at 6:29










  • @Sraw This is a really interesting problem. Can you update your question containing your full code (ie, initialize func, and main), with sample input/output. So others can better understand what it is supposed to do.
    – Ludisposed
    Jun 27 at 8:28










  • @Ludisposed OK, wait a minute.
    – Sraw
    Jun 27 at 8:40
















  • Welcome to Code Review. Asking for advice on code yet to be written or implemented is off-topic for this site. See What topics can I ask about? for reference. Once you have written working code, you're welcome to ask a new question here and we can then help you improve it!
    – Phrancis
    Jun 27 at 6:02










  • @Phrancis Um... I don't understand what you mean? I have read your link and I think I am asking a question about best practice? The snippet given in my question is definitely a worked one, but it cost too much time. I want to know which part can be optimized.
    – Sraw
    Jun 27 at 6:14






  • 1




    @Phrancis I think this is a performance related issue, hence why I'm not voting to close.
    – Daniel
    Jun 27 at 6:29










  • @Sraw This is a really interesting problem. Can you update your question containing your full code (ie, initialize func, and main), with sample input/output. So others can better understand what it is supposed to do.
    – Ludisposed
    Jun 27 at 8:28










  • @Ludisposed OK, wait a minute.
    – Sraw
    Jun 27 at 8:40















Welcome to Code Review. Asking for advice on code yet to be written or implemented is off-topic for this site. See What topics can I ask about? for reference. Once you have written working code, you're welcome to ask a new question here and we can then help you improve it!
– Phrancis
Jun 27 at 6:02




Welcome to Code Review. Asking for advice on code yet to be written or implemented is off-topic for this site. See What topics can I ask about? for reference. Once you have written working code, you're welcome to ask a new question here and we can then help you improve it!
– Phrancis
Jun 27 at 6:02












@Phrancis Um... I don't understand what you mean? I have read your link and I think I am asking a question about best practice? The snippet given in my question is definitely a worked one, but it cost too much time. I want to know which part can be optimized.
– Sraw
Jun 27 at 6:14




@Phrancis Um... I don't understand what you mean? I have read your link and I think I am asking a question about best practice? The snippet given in my question is definitely a worked one, but it cost too much time. I want to know which part can be optimized.
– Sraw
Jun 27 at 6:14




1




1




@Phrancis I think this is a performance related issue, hence why I'm not voting to close.
– Daniel
Jun 27 at 6:29




@Phrancis I think this is a performance related issue, hence why I'm not voting to close.
– Daniel
Jun 27 at 6:29












@Sraw This is a really interesting problem. Can you update your question containing your full code (ie, initialize func, and main), with sample input/output. So others can better understand what it is supposed to do.
– Ludisposed
Jun 27 at 8:28




@Sraw This is a really interesting problem. Can you update your question containing your full code (ie, initialize func, and main), with sample input/output. So others can better understand what it is supposed to do.
– Ludisposed
Jun 27 at 8:28












@Ludisposed OK, wait a minute.
– Sraw
Jun 27 at 8:40




@Ludisposed OK, wait a minute.
– Sraw
Jun 27 at 8:40










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted











  • Do % p early.



    Since the test case is huge, I expect intermediate values you compute to be huge as well. Multiplication of large numbers is a very expensive operation. Try to keep your results in a native range. Consider e.g.



    def modulo_factorial(n, mod):
    result = 1
    for i in range(1, n + 1):
    result = (result * i) % mod
    return result


    Ditto for pow.




  • Do not recompute factorials from scratch. Instead of



    for i in divide:
    temp = factorial(i)
    temp = pow(temp, p - 2, p)
    total = total * temp


    sort divide first. Then computation of each factorial can be started where the previous one ended.



    Also notice that since total is greater than any element of divide, you should compute factorial(total) after the this loop, using the same technique.



    And don't forget to % p early.



  • Most of your imports are never used.






share|improve this answer





















  • I thought the same about the first point. But the code I had (which was the same as yours) was always slower than doing the % mod afterwards (for n <= 10**6). I thought this quite surprising.
    – Graipher
    Jun 27 at 19:55










  • I will try your first point. For the second point and the third point, I have already implement a factorial function like you say, you can see it in my update of question. And the unused imports are imported by default in this practice. As they are default ones, I believe I can pass this case even with these useless imports. Finally, thank you!
    – Sraw
    Jun 28 at 1:26










  • Wow, your first point is really important. Finally I think I get the most important point and pass all the cases.
    – Sraw
    Jun 28 at 1:55










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");

StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f197329%2flongest-palindromes-in-a-string%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted











  • Do % p early.



    Since the test case is huge, I expect intermediate values you compute to be huge as well. Multiplication of large numbers is a very expensive operation. Try to keep your results in a native range. Consider e.g.



    def modulo_factorial(n, mod):
    result = 1
    for i in range(1, n + 1):
    result = (result * i) % mod
    return result


    Ditto for pow.




  • Do not recompute factorials from scratch. Instead of



    for i in divide:
    temp = factorial(i)
    temp = pow(temp, p - 2, p)
    total = total * temp


    sort divide first. Then computation of each factorial can be started where the previous one ended.



    Also notice that since total is greater than any element of divide, you should compute factorial(total) after the this loop, using the same technique.



    And don't forget to % p early.



  • Most of your imports are never used.






share|improve this answer





















  • I thought the same about the first point. But the code I had (which was the same as yours) was always slower than doing the % mod afterwards (for n <= 10**6). I thought this quite surprising.
    – Graipher
    Jun 27 at 19:55










  • I will try your first point. For the second point and the third point, I have already implement a factorial function like you say, you can see it in my update of question. And the unused imports are imported by default in this practice. As they are default ones, I believe I can pass this case even with these useless imports. Finally, thank you!
    – Sraw
    Jun 28 at 1:26










  • Wow, your first point is really important. Finally I think I get the most important point and pass all the cases.
    – Sraw
    Jun 28 at 1:55














up vote
1
down vote



accepted











  • Do % p early.



    Since the test case is huge, I expect intermediate values you compute to be huge as well. Multiplication of large numbers is a very expensive operation. Try to keep your results in a native range. Consider e.g.



    def modulo_factorial(n, mod):
    result = 1
    for i in range(1, n + 1):
    result = (result * i) % mod
    return result


    Ditto for pow.




  • Do not recompute factorials from scratch. Instead of



    for i in divide:
    temp = factorial(i)
    temp = pow(temp, p - 2, p)
    total = total * temp


    sort divide first. Then computation of each factorial can be started where the previous one ended.



    Also notice that since total is greater than any element of divide, you should compute factorial(total) after the this loop, using the same technique.



    And don't forget to % p early.



  • Most of your imports are never used.






share|improve this answer





















  • I thought the same about the first point. But the code I had (which was the same as yours) was always slower than doing the % mod afterwards (for n <= 10**6). I thought this quite surprising.
    – Graipher
    Jun 27 at 19:55










  • I will try your first point. For the second point and the third point, I have already implement a factorial function like you say, you can see it in my update of question. And the unused imports are imported by default in this practice. As they are default ones, I believe I can pass this case even with these useless imports. Finally, thank you!
    – Sraw
    Jun 28 at 1:26










  • Wow, your first point is really important. Finally I think I get the most important point and pass all the cases.
    – Sraw
    Jun 28 at 1:55












up vote
1
down vote



accepted







up vote
1
down vote



accepted







  • Do % p early.



    Since the test case is huge, I expect intermediate values you compute to be huge as well. Multiplication of large numbers is a very expensive operation. Try to keep your results in a native range. Consider e.g.



    def modulo_factorial(n, mod):
    result = 1
    for i in range(1, n + 1):
    result = (result * i) % mod
    return result


    Ditto for pow.




  • Do not recompute factorials from scratch. Instead of



    for i in divide:
    temp = factorial(i)
    temp = pow(temp, p - 2, p)
    total = total * temp


    sort divide first. Then computation of each factorial can be started where the previous one ended.



    Also notice that since total is greater than any element of divide, you should compute factorial(total) after the this loop, using the same technique.



    And don't forget to % p early.



  • Most of your imports are never used.






share|improve this answer














  • Do % p early.



    Since the test case is huge, I expect intermediate values you compute to be huge as well. Multiplication of large numbers is a very expensive operation. Try to keep your results in a native range. Consider e.g.



    def modulo_factorial(n, mod):
    result = 1
    for i in range(1, n + 1):
    result = (result * i) % mod
    return result


    Ditto for pow.




  • Do not recompute factorials from scratch. Instead of



    for i in divide:
    temp = factorial(i)
    temp = pow(temp, p - 2, p)
    total = total * temp


    sort divide first. Then computation of each factorial can be started where the previous one ended.



    Also notice that since total is greater than any element of divide, you should compute factorial(total) after the this loop, using the same technique.



    And don't forget to % p early.



  • Most of your imports are never used.







share|improve this answer













share|improve this answer



share|improve this answer











answered Jun 27 at 17:51









vnp

36.3k12890




36.3k12890











  • I thought the same about the first point. But the code I had (which was the same as yours) was always slower than doing the % mod afterwards (for n <= 10**6). I thought this quite surprising.
    – Graipher
    Jun 27 at 19:55










  • I will try your first point. For the second point and the third point, I have already implement a factorial function like you say, you can see it in my update of question. And the unused imports are imported by default in this practice. As they are default ones, I believe I can pass this case even with these useless imports. Finally, thank you!
    – Sraw
    Jun 28 at 1:26










  • Wow, your first point is really important. Finally I think I get the most important point and pass all the cases.
    – Sraw
    Jun 28 at 1:55
















  • I thought the same about the first point. But the code I had (which was the same as yours) was always slower than doing the % mod afterwards (for n <= 10**6). I thought this quite surprising.
    – Graipher
    Jun 27 at 19:55










  • I will try your first point. For the second point and the third point, I have already implement a factorial function like you say, you can see it in my update of question. And the unused imports are imported by default in this practice. As they are default ones, I believe I can pass this case even with these useless imports. Finally, thank you!
    – Sraw
    Jun 28 at 1:26










  • Wow, your first point is really important. Finally I think I get the most important point and pass all the cases.
    – Sraw
    Jun 28 at 1:55















I thought the same about the first point. But the code I had (which was the same as yours) was always slower than doing the % mod afterwards (for n <= 10**6). I thought this quite surprising.
– Graipher
Jun 27 at 19:55




I thought the same about the first point. But the code I had (which was the same as yours) was always slower than doing the % mod afterwards (for n <= 10**6). I thought this quite surprising.
– Graipher
Jun 27 at 19:55












I will try your first point. For the second point and the third point, I have already implement a factorial function like you say, you can see it in my update of question. And the unused imports are imported by default in this practice. As they are default ones, I believe I can pass this case even with these useless imports. Finally, thank you!
– Sraw
Jun 28 at 1:26




I will try your first point. For the second point and the third point, I have already implement a factorial function like you say, you can see it in my update of question. And the unused imports are imported by default in this practice. As they are default ones, I believe I can pass this case even with these useless imports. Finally, thank you!
– Sraw
Jun 28 at 1:26












Wow, your first point is really important. Finally I think I get the most important point and pass all the cases.
– Sraw
Jun 28 at 1:55




Wow, your first point is really important. Finally I think I get the most important point and pass all the cases.
– Sraw
Jun 28 at 1:55












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f197329%2flongest-palindromes-in-a-string%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Python Lists

Aion

JavaScript Array Iteration Methods