Only 8 gets appened

Hello @S19LPPP0159,

This behavior of your program is due to a syntax error in the following code:
while(temp->next=NULL)

Now, it’s your task to find it.

BTW, even if you would correct this mistake, your program will not pass testcases due to 2 reasons:

  1. The output format of your code does not match with that of the question.
    Solution:
    1.1. replace β€œ->” with " "
    1.2. remove cout<<endl;

  2. You are not taking in account an important part of the question i.e
    k can have values greater than and equal to n.
    Solution:
    Observe the pattern,
    2.1. for k=7, the output is same as that of k=0,
    2.2. for k=8, the output is same as k=1,
    2.3. for k=9, the output is same as k=2,
    and so on…
    Hint: use % operator.

Hope, this would help.
Give a like, if you are satisfied.

1 Like

i Did those changes yet i get 2 wrong and 1 TLE

Please, Share your modified code.

@S19LPPP0159,

I have modified your code.
You can check it here.

Hope, this would help.
Give a like, if you are satisfied.

1 Like