I couldnt come up with a solution that could solve Test set 3, I didnt know Benford's law even existed. But I was able to come up with an Algo for Test set 2
I thought I could throw in a tiny optimization (return if result already found) into my algorithm but it gives an incorrect answer. Although it passes test case 1 and 2 if I comment it out. I dont seem to understand why, would appreciate any insight. Here is my C++ code int main() { int T,U; int num; string Q,R; cin>>T; for(int t=1;t<=T;t++) { cin>>U; unordered_map<char,int> my_map; unordered_map<int,int> unique; for (int i=0;i<10000;i++) { cin>>Q>>R; if (my_map.size() < 10) { for(int j=0;j<R.length();j++) { if (my_map.count(R[j])==0) my_map[R[j]] = 10; } } if (R.length()==Q.length()) { num = Q[0] - 48; if (my_map[R[0]] > num) my_map[R[0]] = num; } unique.clear(); for (auto it=my_map.begin();it!=my_map.end();it++) unique[it->second]=1; //if (unique.size()>=10) // break; } string result("AAAAAAAAAA"); for (auto it=my_map.begin();it!=my_map.end();it++) result[it->second %10] = it->first; cout<<"Case #"<<t<<": "<<result<<"\n"; } return 0; } -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/ea478173-c4e5-4cec-a902-408f48eecc28%40googlegroups.com.