Interview Question
Software Engineer / DevelopersI do not have clear idea but I can share vague idea.
For each internal node there are 9 neighbors including itself. So we can have 2^9 -1 substrings (We can think it like we have a set consisting of 9 elements so total number of non empty subsets is (2^9 -1) )
Similarly, For corner node/element we have 2^4 -1
For edge element : 2^6 -1
off course it includes some duplicate substring also. We need to exclude it.
Similar to Anonymous but may have different understand about the question. Only ea,eb,ec,ed,ef,eg,eh,ei, no e.
There are 8 neighbors, for each one, only "in" or "out" status. For example, a is "in", all other are out, then substring=ea
So 2^8, but all neighbors cannot be "out", so final answer is 2^8-1=255
For 4 corners, 2^3-1=7
For 4 sides, 2^5-1=31
I have a question .. ead and eda .. 2 combinations or one?
- JoshMachine November 04, 2010