Skip to content
Advertisement

Tag: linked-list

Converting String number words to just String number:Java

I’m a beginner coder trying to work on converter for words which should work that way:Input= “zero;six;eight;two” Output = “0682”. But in my case the output I get is “0282”. Are there any solutions to that? Or like maybe I should program differently?. I found that LinkedLists or HashMap could work, if so could you show how? Answer You should

implementation of LinkedList without last node

I have been asked to re-implement a linked list without the use of a tail. So I have to change its methods so it can work without using a tail node. The removeLast method confused me: here is what I tried to do, but it didn’t remove the node. What is wrong with my attempt? Test class Answer You need

Leetcode #2, getting detected a cycle error

I was trying to solve leetcode#2, You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0

Doubly Linked List, Insert Before A Given Node in Java

The method not working: Another add method which is working: A print method to debug: DoublyLinkedList class: LinkedList and Node implementations are very straightforward. Find here: https://www.geeksforgeeks.org/doubly-linked-list/ I first create a linkedlist, insert_front() a value to make the head not null, then use the method above to insert something else. Insertion to front, end, after a node are working, however,

Reverse Linked-List Recursive

I’ve traced through my code to reverse a linked-list using recursion, and I cannot find anything wrong with it, but I know it does not work. Can anyone please explain why? Answer Below is a working version of your code, added with some helping structures:

toString method for a linkedList

I am getting strange output for my toString in my linkedList class. I cannot use any methods, only String concat. So limited in how to approach this. Here is the code: I wrote a JUnit test that: and that noOrderList().toString() comes from: When I run the test I get: Was is the cause of this , in the [, ]

Advertisement