It seems not only me misunderstood the question. Please modify the description, since it's frustrating if you are solving a "different" question. Thanks.
Please expand on how you misunderstood the question, so we what question you thought you were solving. Letting people know how you read it makes it easier to come up with clearer ways to word current and future problems to avoid these mistakes. Just saying it is frustrating and that you misunderstood the question doesn't make it any easier to correct.
I solved the wrong problem also, thought was to "say" the given integer input. After several times of reading the question I understood it in the end. I think we need an example of input/output test case, like input 5, output "111221", so we know we are not expecting "15" as the result.
To me, the misleading part is "Given an integer n, generate the nth sequence". I thought the generated sequences starts with n instead of 1.
It's better to provide some test cases as example, like 1 as '1', 2 as '11', otherwise in common sense, we would think 1 should output as '11', and 2 should output as '12'
Careercup has a same problem, I think its description is better:
"Count and Say problem" Write a code to do following:
n String to print
1 1 1
2 2 1
3 1 2 1 1
Base case: n = 0 print "1"
for n = 1, look at previous string and write number of times a digit is seen and the digit itself. In this case,
digit 1 is seen 1 time in a row... so print "1 1"
for n = 2, digit 1 is seen two times in a row, so print "2 1"
for n = 3, digit 2 is seen 1 time and then digit 1 is seen 1 so print "1 2 1 1"
for n = 4 you will print "1 1 1 2 2 1"
Consider the numbers as integers for simplicity. e.g. if previous string is "10 1" then the next will be "1 10 1 1" and the next one will be "1 1 1 10 2 1"
I think it's better to offer more examples, such as
if n = 4, the sequence is "111221";
if n = 5, the sequence is "312211".
Me too. Totally misleading. I thought it gives an integer n and find its nth sequence.
@boa1150 I already did this problem before, and made the same mistake again this time by starting from n instead of 1. The description has not changed yet.
Are we sure this is the same as current leetcode problem?
I would've guessed if previous string was "101", the next string would be "111011", not "11011" as you've stated.
This is so misleading description. Strongly suggest changing to a better description or add more example!
I think this question is really easy to understand without any other changes. I really can't understand why there are so many people say this question is misunderstanding?
In terms of misunderstanding and my confusion:
well.. barely started looking at the problem and when i input 21 in the test case, the expected output after running code is "311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122211311122122111312211213211312111322211213211321322113311213212322211231131122211311123113223112111311222112132113311213211221121332211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221131112311311121321122112132231121113122113322113111221131221".
not understanding the question itself aside, the expected output FROM THE CODE doesn't even seem to match what is expected in the description
@deeTEEcee Try it from small cases and you'll get it. Good luck!
@robert4 yeah, I was wondering how many terms of the new sequence should the program return...
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.