Can't understand problem in solution I have written!

The solution-code I have written for this “straightening multilevel linkedList” question gives correct answer on my local computer

It also gives correct answer when I run “Compile and Test” on codingBlocks.

But when I “Submit Code”, it gives “Run Error” for all test-cases.

For better understanding of my code to others, I have given precise naming to functions and variables; And also used comments wherever necessary,

Here is my soultion -

Hey @maheshghamand
debug for this
INPUT
[1,2,3,4,5,null,null,null,7,8,9,null,null,11,12]

OUTPUT
[1, 2, 3, 7, 8, 11, 12, 9, 4, 5]

Could you explain, how to convert (logic behind) this array into a multi-level graph as explained in “sample-input to sample-output” of the question !

According logic I have used until, for input you provided, the multilevel-list should look like this -

1->2->3->4->5->null
|  |
|  11-> 12
|
7->8->9->null

I could not understand where to connect “null” properly !

Read its description https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/

OK, thanks for the help.

1 Like

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.