huawei.py-20180413

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr  3 19:25:43 2018

@author: vicky
"""

def manacher(s):
    #预处理
    s='#'+'#'.join(s)+'#'

    RL=[0]*len(s)
    MaxRight=0
    pos=0
    MaxLen=0
    for i in range(len(s)):
        if i<MaxRight:
            RL[i]=min(RL[2*pos-i], MaxRight-i)
        else:
            RL[i]=1
        #尝试扩展,注意处理边界
        while i-RL[i]>=0 and i+RL[i]<len(s) and s[i-RL[i]]==s[i+RL[i]]:
            RL[i]+=1
        #更新MaxRight,pos
        if RL[i]+i-1>MaxRight:
            MaxRight=RL[i]+i-1
            pos=i
        #更新最长回文串的长度
        MaxLen=max(MaxLen, RL[i])
    return MaxLen-1

s='12321abc'
print(manacher(s))

 

copying pyarrow/tests/data/orc/decimal.orc -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/data/orc creating build/lib.linux-x86_64-cpython-310/pyarrow/tests/data/parquet copying pyarrow/tests/data/parquet/v0.7.1.all-named-index.parquet -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/data/parquet copying pyarrow/tests/data/parquet/v0.7.1.column-metadata-handling.parquet -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/data/parquet copying pyarrow/tests/data/parquet/v0.7.1.parquet -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/data/parquet copying pyarrow/tests/data/parquet/v0.7.1.some-named-index.parquet -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/data/parquet creating build/lib.linux-x86_64-cpython-310/pyarrow/tests/interchange copying pyarrow/tests/interchange/__init__.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/interchange copying pyarrow/tests/interchange/test_conversion.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/interchange copying pyarrow/tests/interchange/test_interchange_spec.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/interchange creating build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/__init__.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/common.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/conftest.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/encryption.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_basic.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_compliant_nested_type.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_data_types.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_dataset.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_datetime.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_encryption.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_metadata.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_pandas.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_parquet_file.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet copying pyarrow/tests/parquet/test_parquet_writer.py -> build/lib.linux-x86_64-cpython-310/pyarrow/tests/parquet creating build/lib.linux-x86_64-cpython-310/pyarrow/vendored copying pyarrow/vendored/__init__.py -> build/lib.linux-x86_64-cpython-310/pyarrow/vendored copying pyarrow/vendored/docscrape.py -> build/lib.linux-x86_64-cpython-310/pyarrow/vendored copying pyarrow/vendored/version.py -> build/lib.linux-x86_64-cpython-310/pyarrow/vendored running build_ext creating /tmp/pip-install-y499vs6l/pyarrow_941446448b3048f5a70349495abf2333/build/temp.linux-x86_64-cpython-310 -- Running cmake for PyArrow cmake -DCMAKE_INSTALL_PREFIX=/tmp/pip-install-y499vs6l/pyarrow_941446448b3048f5a70349495abf2333/build/lib.linux-x86_64-cpython-310/pyarrow -DPYTHON_EXECUTABLE=/usr/bin/python3.10 -DPython3_EXECUTABLE=/usr/bin/python3.10 -DPYARROW_CXXFLAGS= -DPYARROW_BUNDLE_ARROW_CPP=off -DPYARROW_BUNDLE_CYTHON_CPP=off -DPYARROW_GENERATE_COVERAGE=off -DCMAKE_BUILD_TYPE=release /tmp/pip-install-y499vs6l/pyarrow_941446448b3048f5a70349495abf2333 Traceback (most recent call last): File "/usr/local/bin/cmake", line 5, in <module> from cmake import cmake ModuleNotFoundError: No module named 'cmake' error: command '/usr/local/bin/cmake' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pyarrow Failed to build pyarrow ERROR: Failed to build installable wheels for some pyproject.toml based projects (pyarrow)
09-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值