Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Ejemplo
- {
- public static void main(String[] args)
- {
- String word = "hola";
- String wholeUni = "hola aloh halo laho ola ddfa daffadfadkjl adrerjlkj arqerhkaf adlfkhlkehrolahdfa rqerq adlkfhalk";
- char[] seq = wholeUni.toCharArray();
- Set<Integer> hash_Set = new HashSet<Integer>();
- String copy =new String(word);
- int total = word.length();
- boolean isEmpty = true;
- for(int i = 0; i < seq.length; i++){
- if(copy.length() >= 0){
- isEmpty = false;
- int idx = copy.indexOf(seq[i]);
- if(idx >= 0){
- total--;
- copy = copy.substring(0, idx) + copy.substring(idx + 1);
- }else{
- total = word.length();
- copy = word;
- }
- }
- if(total == 0 && !isEmpty){
- System.out.println(i - (word.length() -1) + " " + i );
- }
- }
- /*
- indexof y tratar de meterlos en un set,
- si falla es que es una letra repetida
- remover
- */
- }
- public static String sortString(String inputString)
- {
- char tempArray[] = inputString.toCharArray();
- Arrays.sort(tempArray);
- return new String(tempArray);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement