Sort the string

KIndly find the error in this code. This code is a subpart of solution code of problem:
https://hack.codingblocks.com/app/practice/6/p/1121

Hello @sr30,

Your code is not visible to me.
Please share it using Online Coding Blocks IDE.
STEPS:

  1. Paste your code at https://ide.codingblocks.com/
  2. Save it there.
  3. Share the URL generated.

Hello @sr30,

  1. Read the constraints properly:
    1 <= n <= 10^5
    The size of your pair is 100 only:
    pair <string,string> sp[100]

  2. Why pair?
    1 <= key <= number of spaces in each string + 1
    That means there could be more than one columns and more than and equal to zero spaces in the strings.

Also, you have not written the sorting logic. Try to figure out that also.
Hope, this would help.
Give a like if you are satisfied.

Its not working even after giving a custom input which are inside the constraints of my code.

Hello @sr30,

This is because there is a logical error in you tokenfxn().

I have modified your code:


Refer to the comments for better understanding.

Hope, this would help.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.