Skip to main content

All Questions

0 votes
1 answer
50 views

Elements are not inserting properly while creating a linked list in c#

I have the node structure like this for singly-linked list. public class ListNode { public int val; public ListNode next; public ListNode(int val=0, ListNode next=null) { ...
Chaitanya GaneshRaju's user avatar
0 votes
1 answer
717 views

Unable to iterate to next ListNode, since the current node is getting overridden with the listnode.next value

This is a leetcode problem. I saw the solution however while trying to use my own logic, I cannot iterate over to the next node. public ListNode AddTwoNumbers(ListNode l1, ListNode l2) { try { ...
Vemula Dheeraj's user avatar
0 votes
1 answer
117 views

Removing element from Linked List by index

I wrote a simple Linked List generic implementation, just for practice. Everything is working, but when I call RemoveByIndex(0), it does nothing, and I don't know why. public void RemoveByIndex(int ...
John's user avatar
  • 3
-1 votes
1 answer
811 views

How to add an element at an index in singly linked list in C#

I am implementing linked-list data-structure in C#. I am facing below issue. When I am try to add element at an index in singly linked list then it not working. below is my code. Issue is in ...
Devinder Yadav's user avatar
1 vote
3 answers
1k views

How a LinkedList Keeps Track of All Nodes - C#?

I have been struggling trying to develop my own singly linked list, I cant understand how a node is inserted at the end of a Linked List? Here's the code: class LinkedList { private Node head; ...
Jameel Aslam's user avatar
0 votes
1 answer
661 views

Leetcode: Adding two numbers represented in reverse linked list is not working

The following code is not working for the below Input: [2,4,3] [5,6,4] Output: [7,8] Expected: [7,0,8] Why I am not getting 0? Can anyone please help me. /** * Definition for singly-linked list. * ...
Sharif Mamun's user avatar
  • 3,574
-3 votes
1 answer
791 views

get loops in a linked list C#

I have a program to make a linked list in c# like this: class Point { public string Name { get; set; } public List<Point> NextPoints { get; set; } public Point() { ...
Karim Seoudy's user avatar
2 votes
7 answers
7k views

Reverse a singly-linked list with and without using recursion

I am new to data structures, and I know this is a very common question to ask. But I know LinkedList in .NET is doubly-linked, so how I will write code for a singly-linked list in C#. Could someone ...
Pritam Karmakar's user avatar