Rohitraman2006
BAN USER- 3of 3 votes
AnswersFind the longest words in a given list of words that can be constructed from a given list of letters.
- Rohitraman2006 in United States
Your solution should take as its first argument the name of a plain text file that contains one word per line.
The remaining arguments define the list of legal letters. A letter may not appear in any single word more times than it appears in the list of letters (e.g., the input letters ‘a a b c k’ can make ‘back’ and ‘cab’ but not ‘abba’).
Here's an example of how it should work:
prompt> word-maker WORD.LST w g d a s x z c y t e i o b
['azotised', 'bawdiest', 'dystocia', 'geotaxis', 'iceboats', 'oxidates', 'oxyacids', 'sweatbox', 'tideways']
Tip: Just return the longest words which match, not all.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding
possible modification can be, do a 6k+/-1, then do a trial division (divide number by all integers between 2 and sqrt(number)).
Per wiki, sieve of Eratosthenes is a fast method to find primes up to 10 million.
This is not always correct. (Example: 35)
The process of 6k+/-1 gives possible false positives. Though this is good process to indicate which number is NOT a prime number.
I recall seeing this before. The same link also says this:
"The sieve of Eratosthenes is one of the most efficient ways to find all of the smaller primes (below 10 million or so)" - that is only 7 0's or 8 total digits. It doesn't say anything about 11 digits.
Keeping this in mind, will the sieve really be that much better than Phoenix's method?
your logic is too good! Strange I never read about this before.
- Rohitraman2006 July 24, 2014Could anyone please explain the question a bit in detail? My confusion stems from the concept that matrices are usually read 1 row at a time - top down. I am unable to see 6 7 8 9 as adjacent numbers, unless seen visually. matrix [row] [column] is the general declaration i have seen till now. A lot of folks are attempting the question means I am missing something here. Appreciate any help. Thanks!
- Rohitraman2006 July 23, 2014
The program runs correctly - tried all combinations of cycles, duplicates, etc.
- Rohitraman2006 July 29, 2014Output to set input in program is:
A->B
B->C
C->D
What would be the complexity of this program? O(N logN) or O(n^2)?