#-*-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. IntelliJ IDEA 控制台中文乱码解决方案

    配置Intellij的配置文件(在idea安装目录bin目录下) 打开Intellij的根目录,找到下图的两个文件(根据你的系统是32位或64位选择其中一个配置文件),在配置文件中添加: -Dfile ...

  2. springboot整合redis-sentinel支持Cache注解

    一.前提 已经存在一个redis-sentinel集群,两个哨兵分别如下: /home/redis-sentinel-cluster/sentinel-1.conf port 26379 dir &q ...

  3. qt字符数组转ASCII(十六进制)

    接收网络传输数据 QByteArray  array;//显示字符串 QString str = QString::fromLocal8Bit(array); m_receiveTxt.append( ...

  4. Dev gridcontrol 添加多列按钮

    gridcontrol中添加按钮的步骤: 1. 把列的ColumnEdit属性设置为RepositoryItemButtonEdit 2. 把TextEditStyle属性设置为HideTextEdi ...

  5. 移动端--用PX为单位+JS框架 实现页面布局

    一:大家先下载metahandler.js 二:准备一个用px实现的移动页面(宽度固定死的页面),引入metahandler.js框架 1.视口设置 width=640,是根据psd图来设置,有多宽设 ...

  6. NotePad++ 添加HEX-Editor插件

    步骤: 一.下载插件 https://github.com/chcg/NPP_HexEdit/releases 二.选择插件版本 Notepad 官网客服提示:32bit Notepad++可以使用常 ...

  7. JavaScript基础视频教程总结(101-110章)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  8. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  9. Equal 路由类

    1.Route 原型 class Route { /* 获取请求路径和查询字符串 */ /* 获取模块.控制器.动作名称 */ /* 获取 URI 参数 */ }

  10. Connect To Ubuntu 16.04 / 17.10 / 18.04 Desktop Via Remote Desktop Connection (RDP) With Xrdp

    [1] https://websiteforstudents.com/connect-to-ubuntu-16-04-17-10-18-04-desktop-via-remote-desktop-co ...