Tushar
BAN USER
Comments (3)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 1 vote
The solution to this is really easy..
findHits(char *sol, char *guess)
{
int hits = 0, phits = 0;
int arrS[4]={0,0,0,0}, arrG[4]={0,0,0,0};
while(*sol != '\0') {
if(*sol == *guess) {
hits++;
}
else {
arrS[getIndex(*sol)]++;
arrG[getIndex(*guess)]++;
}
sol++; guess++;
}
for(int i = 0i i<4; i++) {
phits += min(arrS[i],arrG[i]);
}
// print hits n phits
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Khoa your solution prints only ((())), (()) kind of strings... but the idea u gave in ur 1st post is good..
- Tushar February 18, 2007