Question
Autocomptete

Doug was using Google and was amazed to see the autocomptete feature How autocomptete works it search the database for all the possible words that can be formed using the characters that are provided by user (as input)

For ex If a user type 'cis' in the search bar then suggestions would be

• cisco

• cist

• cissp

• cism

• cisa
He thought about applying the same feature in his search engine. In his prototype he took a string as domain which contained all the words he could search.
As his designer you have to tell him how many autocomptete options will be provided to him if something is entered in the input field.

This is my code for the following problem.

```
import java.util.ArrayList;
import java.util.List;

public class Test {

public static void main(String[] args) {

    String input1 = "Hello world with warm welcome from Mr.kajezevu";
    String input2 = "w";
    //output should be any word starting with w i.e {world,warm,welcome}

    List < String > l = new ArrayList < String > ();

    String[] str = input1.split("\\s+");//splits a given string at spaces
    for (int i = 0; i < str.length; i++) {
        if (str[i].length() >= input2.length()) { // checks if the length of input2 is not greater than the str[i] selected
            if (input2.equals(str[i].substring(0, input2.length()))) { //comparing the two string if they are equal
                l.add(str[i]);
            }

        }
    }

    String[] result = l.toArray(new String[l.size()]);

    for (int i = 0; i < result.length; i++) {
        System.out.println(result[i]);
    }
}

}

```

**But my solution is passing only one test case and also its failing complexity case.**
i can't figure out whats wrong with it.