public class Solution {
public static boolean canConstruct(String ransom, String magazine){if(ransom.length()> magazine.length()){return false;}int[] cap = new int[26];for(char c : ransom.toCharArray()){int index = magazine.indexOf(c, cap[c -'a']);if(index ==-1){return false;}
cap[c -'a']= index +1;}return true;}
public staticvoidmain(String[] args){
System.out.println(canConstruct("ads","adacs"));}}