How to find smallest substring which contains all characters from a given string?

后端 未结 15 1111
灰色年华
灰色年华 2020-12-02 07:36

I have recently come across an interesting question on strings. Suppose you are given following:

Input string1: \"this is a test string\"
Input strin         


        
15条回答
  •  天命终不由人
    2020-12-02 08:29

        String s = "xyyzyzyx";
        String s1 = "xyz";
        String finalString ="";
        Map hm = new HashMap<>();
        if(s1!=null && s!=null && s.length()>s1.length()){
            for(int i =0;i t = new HashMap<>();
            int start =-1;
             for(int j=0;js.length()){
                                 break;
                             }
                             start = j;
                         }
                     }
                     if(hm.equals(t)){
                        t = new HashMap<>();
                        if(finalString.length()

提交回复
热议问题