4 kyu
Fastest Code : Count animals
94 of 124myjinxin2015
Description:
This is the Performance version of coding 3min series. If your code runs more than 6000ms, please optimize your code or try the simple version
Task:
Give you some chars
, and they can combine many animal names.
Return the maximum number of animal names that can be combined by chars.
Animal names have been preload by variable names
One char can not use twice, for example:
chars="goatcode"
When you got a "dog" first time, chars left "atcoe",
second time you can got a "cat".
result=2
When you got a "goat" first time, chars left "code",
no animals will be found at next time.
result=1
So we should return the maximum number, sc("goatcode")=2
Examples:
names=["dog","cat","bat","cock","cow","pig","fox",
"ant","bird","lion","wolf","deer","bear","frog",
"hen","mole","duck","goat"]
sc("dogcat")=2("dog" and "cat")
sc("bcaatt")=2("bat" and "cat")
sc("dogdog")=2("dog" and "dog")
sc("dopig")=1(only contains one of "dog" or "pig")
some corner case:
sc("goatcode")=2 should return 2("dog","cat"), not 1("goat")
sc("cockdogwdufrbir")=4
should return 4("cow","duck","frog","bird") not 2("cock" and "dog")
Series:
Puzzles
Games
Similar Kata:
Stats:
Created | Apr 16, 2016 |
Published | Apr 16, 2016 |
Warriors Trained | 645 |
Total Skips | 87 |
Total Code Submissions | 833 |
Total Times Completed | 124 |
JavaScript Completions | 94 |
Haskell Completions | 26 |
Python Completions | 7 |
Total Stars | 35 |
% of votes with a positive feedback rating | 93% of 48 |
Total "Very Satisfied" Votes | 42 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 4 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 5 kyu |