Abhi complexity q*log n*log n hai ....ham ese kar sakte h ki new tree bnale har baar?

sir pehle or abh vale code mei kya differnce tha??

abh sabh test case pass , wow :slight_smile: tle gayab?? like kya chnge kiya apne/

@Muskan-Gupta-598128740703036,
In my previous code I had put NULL values in the tree arraylist.

Now when I was building the tree, the arraylist that had to placed in my tree arraylist, instead of replacing the NULL, it was adding it at that particular index and shifting the arraylist ahead by 1 and adding a new arraylist.
Example:
tree = [null, null, null] and tree is of the type Arraylist which means we will use tree to store arraylists of the type Long.

Now I have another arraylist small of the type Long.
And small = [1,2,3]

Now if I do tree.set(1, small)

My new tree will become: [null, [1,2,3], null,null]

This was a huge error.

To correct this: I put empty arraylist of type long in tree.
So my tree was: [ [ ] , [ ] , [ ] ]
And then I did: tree.get(index).add(element)

Hence no new arraylist was added instead the element was appended in the arraylist of type long inside tree.

So if I do: tree.get(1).add(1) , tree will become: [ [ ] , [1, ] , [ ] ]

sir you are amazing :slight_smile: , pura samjh aa gya abh…no doubts …aap ta hi ho toh mere doubts aap le liya kro kyuki mostly ta c++ ke hai i guess…toh unhe problem hoti h shayad java ka code debug krne mei

1 Like

Hey @Muskan-Gupta-598128740703036
I see you have reopened this doubt
How can I help you ?

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.