Advertisement

Java经典算法10大-KMP

阅读量:

字符串匹配问题:

1.暴力匹配

复制代码
 public class ViolenceMatch {

    
     public static void main(String[] args) {
    
     String str1 = "硅硅谷 尚硅谷你尚硅 尚硅谷你尚硅谷你尚硅你好";
    
     String str2 = "尚硅谷你尚硅你好";
    
     int index = violenceMatch(str1, str2);
    
     System.out.println("index=" + index);
    
     }
    
  
    
     //暴力匹配算法
    
     public static int violenceMatch(String str1, String str2) {

全部评论 (0)

还没有任何评论哟~