UVa 10815

From Algorithmist
Jump to: navigation, search

Contents

[edit] 10815 - Andy's First Dictionary

[edit] Summary

Keep track of how many words are there in the input, defining a word as a contiguous sequence of alphabets, case-insensitive.

[edit] Explanation

There are many ways to do this - with a trie, a binary tree, a set, a hash table, a skiplist, among others.

[edit] Gotchas

  • If you simply read the input word-by-word (like using scanf("%s",word) and cin etc.), the 'word' you get might actually contain multiple words. See the input/output below for the idea.
  • A better alternative would be to handle the input line-by-line and use a "string tokenizer" (like strtok() in C and Class StringTokenizer in java). You might need to think carefully about the (list of) delimiters though.

[edit] Input

this"is"a"really"long"word
good100cats
good22dogs

[edit] Output

a
cats
dogs
good
is
long
really
this
word
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox