evhiness
BAN USER
Comments (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
I'm assuming if a character from a word is used than the entire words should be used.
Then:
1. Create an array of n hashtables that carry their initial value as well where n = length of dict;
2. Push each character from each word onto their hash table
3. Check if the long string can be created without any hash table bucket being negative.
4. Check that if current value < initial value, that each bucket is empty.
O(n) where n = sum of all of the characters in the words of dict[]
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
A. Depends one what invariants are require on the linked list. O(1) for front or back insertion depending on implementation, O(n) if sortedness is needed to be maintained.
- evhiness September 17, 2016B. Any hashmap worth its salt should be O(1) or at the maximum O(logn) for functional languages.