#-*-coding:utf-8-*-
#########################################################################
# Copyright (C) 2017 All rights reserved.
#
# FileName:GetLongestSubString.py
# Creator: x'x'x@xxx.com
# Time:06/02/2017
# Description:
#
# Updates:
#
#########################################################################
#!/usr/bin/python
# please add your code here!
import re;
import sys;
import time;
def PrintUsage():
sys.stderr.write("program [IN]\n");
sys.exit(1);
class Solution:
def GetLongestSubString(self,s1,s2):
'''
compute longest substring of input string s1 and s2
'''
maxLen = 0;
endIndex = 0;
print("s1="+s1);
print("s2="+s2);
if ( len(s1) == 0 or len(s2) == 0 ):
return "";
table=[[] for i in range(len(s1))];
for i in range(len(table)):
table[i]=[0 for j in range(len(s2))];
for i in range(0,len(s1)):
for j in range(0,len(s2)):
if ( i == 0 or j == 0 ):
if ( s1[i]==s2[j] ):
table[i][j] = 1;
if ( table[i][j] > maxLen ):
maxLen = table[i][j];
endIndex = i;
else:
if ( s1[i]==s2[j] ):
table[i][j] = table[i-1][j-1]+1;
if (table[i][j] > maxLen):
maxLen = table[i][j];
endIndex = i;
print(table);
return s1[endIndex-maxLen+1:endIndex+1];
if (__name__=="__main__"):
if (len(sys.argv) != 1):
PrintUsage();
sys.exit(1);
starttime = time.clock();
s1="gcdef";
s2="abcdef";
sol = Solution();
print(sol.GetLongestSubString(s1,s2));
endtime = time.clock();
interval = endtime - starttime;
sys.stderr.write("%s has finished congratulations!\n"%str(sys.argv[0]));
sys.stderr.write("time elapse:%f\n"%interval);

newwork setup的更多相关文章

  1. 使用Setup Factory安装包制作工具制作安装包

    在我们开发完软件后,除了极个别案例我们把整个目录复制给客户用外,我们一般都需要做成安装包,方便整个软件的部署操作,以安装包的部署操作可能简单的是复制文件,也可能包括一些注册表.数据库等额外的操作,不过 ...

  2. Hive-0.x.x - Enviornment Setup

    All Hadoop sub-projects such as Hive, Pig, and HBase support Linux operating system. Therefore, you ...

  3. C/S打包 客户端/windows程序 Inno Setup

    之前介绍过InstallShield打包工具,本文再介绍更加方便的打包工具Inno Setup Inno Setup相对来说,比InstallShield更容易使用,不需要去等VS去创建项目,只要提供 ...

  4. A couple of notes about .NET Framework 4.6 setup behaviors

    https://blogs.msdn.microsoft.com/astebner/2015/06/17/a-couple-of-notes-about-net-framework-4-6-setup ...

  5. Appium for iOS setup

    windows下appium设置 之前研究了一段时间的appium for native app 相应的总结如下:                                           ...

  6. RIDE -- Robot Framework setup

    RobotFramework 是一款基于python 的可以实现关键字驱动和数据驱动并能够生成比较漂亮的测试报告的一款测试框架 这里使用的环境是 python-2.7.10.amd64.msi RID ...

  7. [Tool]Inno Setup创建软件安装程序。

    这篇博客将介绍如何使用Inno Setup创建一个软件安装程序. Inno Setup官网:http://www.jrsoftware.org/isinfo.php. 可以下载到最新的Inno Set ...

  8. python setup.py 管理

    发布项目遇到了坑……特此记录. How to write setup.py: https://docs.python.org/2/distutils/setupscript.html Setup.py ...

  9. inno setup读取注册表遇到的一个坑

    一.背景 目前,公司针对PR开发的一个插件需要发布到64位系统上.该插件包括一个prm格式的文件和若干个DLL文件.其中,prm文件需要复制到PR公共插件目录下,DLL需要复制到Windows系统目录 ...

随机推荐

  1. Spring-bean的自动装配

    bean的自动装配:可以让一个bean对象自动的引用其他bean byType:按照类型进行装配.  缺点:如果在IOC容器中存在多个类型相同的bean的时候,会出现异常. <bean id=& ...

  2. 关于canvas补充说明

    上篇文章提到的canvas画布,用到f2组件,组件地址https://gw.alipayobjects.com/os/antv/assets/f2/3.0.0/f2.js或利用npm下载:npm in ...

  3. Acoustic modelling from the signal domain using CNNs

    3. Neural network architecture 此处描述了在本文当中所使用的网络结构,和所提取的关键特征(key features).首先,描述了两个新型的网络结构:the networ ...

  4. 对TIMIT数据进行格式转换(SPHERE2WAV(RIFF))

    首先,转换sph2pipe工具所在文件夹(此工具为LDC所提供的SPHERE音频文件转换工具) cd '/home/dream/Research/kaldi-master/tools/sph2pipe ...

  5. 第四周助教工作总结——NWNU李泓毅

    1.    助教博客链接: https://www.cnblogs.com/NWNU-LHY/ 2.    作业要求链接: www.cnblogs.com/nwnu-daizh/p/10487329. ...

  6. Git使用(二、分支的创建和上传)

    介绍使用TortoiseGit创建分支并push到gitlab项目库,转载请注明出处. 一.创建一个新的文件夹,把要待编辑的工程从gitlab上pull到该文件夹. 其中URL从gitlab的对应项目 ...

  7. 解决jenkins shell执行sonar-scanner提示命令存在的问题

    通过jenkins的以下三个方式去执行sonar-scanner,抛如下错误. Send files or execute commands over SSH before the build sta ...

  8. 背水一战 Windows 10 (93) - 选取器: FileOpenPicker, FolderPicker, FileSavePicker

    [源码下载] 背水一战 Windows 10 (93) - 选取器: FileOpenPicker, FolderPicker, FileSavePicker 作者:webabcd 介绍背水一战 Wi ...

  9. 每天学点SpringCloud(四):Feign的使用及自定义配置

    Feign:SpringCloud的官网对它的定义是这样的: 是一个声明式的Web服务客户端.它支持Feign本身的注解.JAX-RS注解以及SpringMVC的注解.Spring Cloud集成Ri ...

  10. SpringMVC框架四:异常处理器

    .异常分为:预期异常.运行时异常 dao.service.controller三层中有异常,依次向上抛出直到SpringMVC处理. 而SpringMVC交给HandlerExceptionResol ...