Skip to content
Advertisement

Tag: linked-list

How can I insert an Item at the end of the List?

I am working on a project for my Data Structures class that asks me to write a class to implement a linked list of ints. Use an inner class for the Node. Include the methods below. Write a tester to enable you to test all of the methods with whatever data you want in any order. I have a method

Flatten a Multilevel Doubly Linked List leetcode

You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in the example

Custom LinkedList constructor with array as a parameter

I’ve written this program to implement a LinkedList. There are 2 classes: Node and IntLinkedList and the relationship between them is aggregation. In the IntLinkedList class, the constructor’s parameter is an array and I’ve tried to use a for-each loop to add the data of the array to the linked list. Here is my code: Node.java IntLinkedList.java I’ve tried for

Adding two linked lists in java solution results in time limit exceeded

the problem on leetcode: https://leetcode.com/problems/add-two-numbers/ My solution results in time limit exceeded and I cannot understand what’s wrong with my code: Answer It looks like you are never resetting the carry (c) back to 0. Therefore, once you set it to a non-zero value, the loop will never end. You should reset it to 0 at the start of each

Advertisement