Code Problem / Data Structures and Algorithms / Linked Lists

Categories: Code Problem / Data Structures and Algorithms / Recursion (32) Code Problem / Data Structures and Algorithms / Binary Search (30) Code Problem / Data Structures and Algorithms / Linked Lists (26) Code Problem / Data Structures and Algorithms / Backtracking (26) Code Problem / Data Structures and Algorithms / Stacks and Queues (25) Code Problem / Data Structures and Algorithms / Hashing (24) Databases / SQL / Backup and Recovery (19) Code Problem / Data Structures and Algorithms / Arrays and Strings (19) Databases / SQL / Database Normalization (18) Code Problem / Data Structures and Algorithms / Time Complexity (17) Databases / SQL / Locking (16) Databases / SQL / Replication (15) Databases / SQL / SQL Queries (13) Code Problem / Data Structures and Algorithms / Graphs (13) Databases / SQL / Database Security (13)  More...

Recent solutions:

Check these solutions from our community:
Code Problem / Data Structures and Algorithms DifficultyMedium Python
Given a singly linked list, reverse the order of the elements in the list.
About this solution: This is a good solution that correctly reverses a singly linked list. The approach is clear and easy to follow.
Nov 22
Code Problem / Data Structures and Algorithms DifficultyMedium C#
Given a singly linked list, this code problem determines if the linked list is a palindrome.
About this solution: The candidate's solution correctly determines whether a singly linked list is a palindrome. The candidate uses a stack to store the first half of the linked list, and then compares the values in the stack to the second half of the linked list. If the values are not equal, then the linked list is not a palindrome. This is a correct approach to solving the problem.
Nov 21
Code Problem / Data Structures and Algorithms DifficultyMedium Python
To find the middle node of a singly linked list, simply traverse the list until you reach the middle. If the list has an even number of nodes, return the node at the end of the first half of the list.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The approach is also optimal, as it only requires one pass through the list.
Nov 20
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
This problem is about reversing a linked list. Given a linked list, the goal is to reverse the order of the nodes in the list. For example, if the input list is 1 -> 2 -> 3 -> 4 -> 5, the output should be 5 -> 4 -> 3 -> 2 -> 1.
About this solution: The candidate's solution is correct and uses a stack to reverse the order of the nodes in the list. The time complexity of the solution is O(n) and the space complexity is O(n).
Nov 19
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This problem asks you to reverse a singly linked list. An example input is given as 1->2->3->4->5, and the expected output is 5->4->3 ->2->1.
About this solution: This solution is complete and solves the problem. The approach is to reverse the linked list by changing the next pointers of each node. The solution first sets the next pointer of the head node to NULL, then iterates through the linked list, setting the next pointer of each node to the previous node, and finally returns the previous node (which is the new head of the reversed linked list).
Nov 19
Code Problem / Data Structures and Algorithms DifficultyHard C++
This problem asks you to reverse the order of a singly linked list. For example, if the input list is 1->2->3->4->5, the output should be 5 ->4->3->2->1.
About this solution: The candidate's solution correctly reverses the order of a singly linked list. The approach is clear and easy to follow.
Nov 18
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This problem asks you to write a function that takes in the head node of a singly linked list and a value, and returns the node with the given value. If the value is not present in the linked list, return null.
About this solution: The candidate's solution correctly implements a function to find a node in a singly linked list by its value. The candidate's use of a while loop to iterate through the list is an efficient way to find the desired node. The candidate's solution is optimal in that it correctly implements the function and efficiently iterates through the list.
Nov 18
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This problem asks you to reverse the order of the nodes in a singly linked list. For example, if the input list is 1->2->3->4->5, the output should be 5->4->3->2->1.
About this solution: The candidate's solution correctly reverses the order of the nodes in a singly linked list. The approach is straightforward and easy to follow.
Nov 11