you give 0indexed string s target you letter s rearrange form new stringsreturn maximum number copy target form take letter s rearrange Example 1input s ilovecodingonleetcode target codeoutput 2explanationfor copy code letter indice 4 5 6 7for second copy code letter indice 17 18 19 20the string form ecod code rearrange codeWe copy code return 2example 2Input s abcba target abcoutput 1explanationwe copy abc take letter index 0 1 2we copy abc return 1Note extra b index 3 4 reuse letter c index 2 second copy abcexample 3Input s abbaccaddaeea target aaaaaoutput 1explanationwe copy aaaaa take letter index 0 3 6 9 12we copy aaaaa return 1 Constraints1 slength 1001 targetlength 10s target consist lowercase english letter