Index.java
public class Index
{
public static void main(String[] args)
{
int minLength = Integer.parseInt(args[0]);
int minOccurrence = Integer.parseInt(args[1]);
String[] words =
StdIn.readAllStrings();
BST>
st = new BST>();
for (int i = 0; i < words.length;
i++)
{
String s = words[i];
if (s.length() < minLength)
continue;
if (!st.contains(s))
{
st.put(s, new
Queue());
}
Queue q = st.get(s);
q.enqueue(i);
}
for (String s : st)
{
Queue q = st.get(s);
if (q.length() >= minOccurrence)
{
StdOut.println(s + ":
" + q);
}
}
}
}
No comments:
Post a Comment