Asked in 1st and 2nd interview at campus placement at IIIT Gwalior.
An 8 x 8 char array is provided with random letters. You have to tell if a given string occurs.
eg
String to find = "computer"
Array[] = {
b b b b b b b b
b b b c b b b b
b b o b b b b b
b b b m p b t b
b b b u b u b e
b b b t b b b r
b b b e b b b b
b b b r b b b b
}
Ans : Available
Bool CheckStr(char str[]. charA[m][n])
{
Int HT[256];
For(int i=0;i<256;i++)
HT[i]=0;
For(int i=0;i < m;i++)
For(int j=0;j < n;j++)
HT[A[i][j]]++;
Int src=0;
Do{
If(HT[str[src]]>0)
HT[str[src]]--;
Else return false;
} while(str[++src])
Return true;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment