题解 | #统计字符#

公共子串计算

http://www.nowcoder.com/practice/98dc82c094e043ccb7e0570e5342dd1b

LCS 模板代码

import java.util.Scanner;

/**
 * @author Fanqingle
 * Created by Administrator on 2022-05-06 03:55
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String string = sc.nextLine();
        String  subString = sc.nextLine();
        System.out.println(LCS(string, subString));

    }

    public static int LCS (String str1,String str2){
        String result = "";
        int start = 0,end =1;
        while(end <= str2.length()){
            String subStr = str2.substring(start,end);
            if(str1.contains(subStr)){
                result = subStr;
            }else{
                start++;
            }
            end ++;
        }
        return result.length();
    }

}

全部评论

相关推荐

12-05 18:09
已编辑
广东药科大学 后端工程师
点赞 评论 收藏
分享
不知道怎么取名字_:两个方向 1.简历针对性准备下 2.面试前也需要准备的 主要还是要看各个公司需求,看公司行业和岗位描述,那里面已经写了对技术的需求,一份简历,不可能和所有嵌入式岗位都匹配的
投递北京经纬恒润科技股份有限公司等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务