# Why 101101 is not a result when input is 6?

• My result is:
["100001","101101","106901","108801","109601","110011","111111","116911","118811","119611","160091","161191","166991","168891","169691","180081","181181","186981","188881","189681","190061","191161","196961","198861","199661","600009","601109","606909","608809","609609","610019","611119","616919","618819","619619","660099","661199","666999","668899","669699","680089","681189","686989","688889","689689","690069","691169","696969","698869","699669","800008","801108","806908","808808","809608","810018","811118","816918","818818","819618","860098","861198","866998","868898","869698","880088","881188","886988","888888","889688","890068","891168","896968","898868","899668","900006","901106","906906","908806","909606","910016","911116","916916","918816","919616","960096","961196","966996","968896","969696","980086","981186","986986","988886","989686","990066","991166","996966","998866","999666"]

But the given result is:
["100001","110011","111111","116911","118811","119611","160091","161191","166991","168891","169691","180081","181181","186981","188881","189681","190061","191161","196961","198861","199661","600009","610019","611119","616919","618819","619619","660099","661199","666999","668899","669699","680089","681189","686989","688889","689689","690069","691169","696969","698869","699669","800008","810018","811118","816918","818818","819618","860098","861198","866998","868898","869698","880088","881188","886988","888888","889688","890068","891168","896968","898868","899668","900006","910016","911116","916916","918816","919616","960096","961196","966996","968896","969696","980086","981186","986986","988886","989686","990066","991166","996966","998866","999666"]

I wonder why numbers such as 101101 is not valid?

• I can't reproduce this. Can you post your code?

• Yes. I can. But my concern is whether "101101" is a valid strobogrammatic number. If it is, why the given result does not have it.

• Yes, it is. But like I said, can't reproduce your problem, meaning I do get "101101" in the expected output.

• Really? Here is my code:

``````public List<String> findStrobogrammatic(int n) {
if (n <= 0) {
return result;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < n; i++) {
sb.append('0');
}
if (n == 1) {
}
findStrobogrammaticHelper(result, sb.toString(), 0);
return result;
}

private void findStrobogrammaticHelper(List<String> result, String str, int index) {
if (str.charAt(0) != '0') {
}
if (index > (str.length() - 1) / 2) {
return;
}

StringBuffer sb;
sb = new StringBuffer(str);
sb.setCharAt(index, '1');
sb.setCharAt(str.length() - 1 - index, '1');
findStrobogrammaticHelper(result, sb.toString(), index + 1);

if (index != str.length() - 1 - index) {
sb = new StringBuffer(str);
sb.setCharAt(index, '6');
sb.setCharAt(str.length() - 1 - index, '9');
findStrobogrammaticHelper(result, sb.toString(), index + 1);
}

sb = new StringBuffer(str);
sb.setCharAt(index, '8');
sb.setCharAt(str.length() - 1 - index, '8');
findStrobogrammaticHelper(result, sb.toString(), index + 1);

if (index != str.length() - 1 - index) {
sb = new StringBuffer(str);
sb.setCharAt(index, '9');
sb.setCharAt(str.length() - 1 - index, '6');
findStrobogrammaticHelper(result, sb.toString(), index + 1);
}
}``````

• Just like I thought. 101101 isn't missing in the expectation but in your result.

• You are right. I made a mistake. Thank you very much.

• Yes , and I think 00 should also be included when n = 2

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.