Skip to main content

All Questions

0 votes
1 answer
126 views

Find kth node from the end

I written below function to find kth node from the end. However, one hidden test case is failing. Please let me know what is wrong with below code. def find_kth_from_end(l, k): slow = l.head ...
meallhour's user avatar
  • 15.7k
0 votes
2 answers
125 views

Check if the Linked List is Palindrome or not

When I try to check whether the linked list is palindrome or not, the following code gives me the error. My Approach is: Step 1:- I am reversing the linked list (temp = reverseLL(head). Step 2:- ...
Ratnesh's user avatar
  • 15
-1 votes
1 answer
65 views

Reverse the Linked List using Recursion

I am using recursion to reverse the linked list but not getting the result. Whenever I am using the following code for the input [1,2,3,4,5,6,-1], it shows me the result [1->None]. I am not getting ...
Ratnesh's user avatar
  • 15
0 votes
1 answer
220 views

How __iter__ works for printing linked list

I'm trying to learn linked lists and I'm stuck at the point where the instructor wrote down the __iter__ method. Although I particularly don't understand the part where it says while node, node = node....
VRM's user avatar
  • 113
0 votes
1 answer
187 views

Merge linked lists from dictionary

I am trying to solve the Merge K sorted lists Idea behind the solution: Loop through the list of linkedlists and add each node to the dictionary with the value as key and node as value. In case of ...
Nizar Kadri's user avatar
0 votes
2 answers
522 views

my code for linked list is printing address in python

class Node: def __init__(self, data = None, next = None): self.data = data self.next = next class link: def __init__(self): ...
Aditya Parihar's user avatar
0 votes
0 answers
25 views

Linked List data structure actual meaning of return Node itself

why we can get pointer1's value by only using return pointer1 in the following code. (I cannot understand why we don't need to use return pointer1**.value**) Maybe because of some setting in the ...
杉本裕樹's user avatar
0 votes
1 answer
452 views

Getting frequency count while inserting in linked list

I have created two classes for this practice of singly linked list. I wanted to count the frequency of the newly added words while they are being added to the list. But it seems like every time the ...
mismes_f's user avatar
0 votes
1 answer
177 views

Implementing a find node function for singly linked list

I need to create a find node function for singly linked list in python. Find: this method takes a value as a parameter, and returns the index of the first node which contains this value. If no nodes ...
thepythongirl's user avatar
0 votes
1 answer
349 views

Implementing a delete node by index value for singly linked list

I need to write a function that deletes a node at the given index value.The index value is passed as a parameter. Delete: this method deletes a node from the linked list. If an index is passed as a ...
thepythongirl's user avatar
0 votes
0 answers
38 views

Why does my Linked List doesn't print all values?

I am trying to print linked list with insert function in following order : John Ben Matthew For whatever reason I am unable to print past "John" even though I am looping using while in the ...
jan_w's user avatar
  • 1
0 votes
1 answer
2k views

How to push all user input at a time in a single row to a Linked List in Python?

Here's the code: class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.last_node = ...
Codenoob's user avatar
0 votes
2 answers
44 views

I'm trying to make my basics strong with data structures and linked lists, I keep facing this error

Here is the code: class Node: def __init__(self, data, next): self.data = data self.next = None class Linked List: def __init__(self, data): self.data = data self....
kavili vishnu's user avatar
0 votes
1 answer
81 views

Wrong value for determining Node length in Circular Linked List

I would like to know what I might be doing wrong in trying to find the number of nodes connected in a loop. Here is my implementation in python. # Defined Node class class Node(object): data = 0 ...
emalinga's user avatar
3 votes
2 answers
2k views

Python LinkedList with 2 pointers

class Node: def __init__(self, node_data): self.data = node_data self.next = None class LinkedList: def __init__(self): self.head = None self.tail = None ...
mateo's user avatar
  • 103

15 30 50 per page