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

后端 未结 15 1132
灰色年华
灰色年华 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 08:17

    JavaScript solution in bruteforce way:

    function shortestSubStringOfUniqueChars(s){
    	var uniqueArr = [];
    	for(let i=0; i

提交回复
热议问题