Tags » Linked List

Merge Two/K Sorted List

Merge Two Sorted Lists


Walk through two lists and append the smaller node to the end of the final list. If exhaust one list, append the other list directly to the final list. 240 more words

AI movement

Since the environment is done, we can utilise our environment vector to create a route-pathing algorithm for our AI. Our vector already contains information regarding whether a cell contains an obstacle or not, so we can use this to our advantage. 424 more words

Low-Level Programming

Linked List Manipulations

Reverse a singly linked list

Two pointers prev and curr, walk through the array until curr hits null. Each time 1) save next, revert curr’s next to prev. 71 more words

Intersection of Two Linked Lists

Given two linked lists, find the first node the two lists intersect. Return null if they do not intersect.


This is the naive solution uses a hash set. 95 more words

Remove Duplicates From Sorted List

Given a sorted linked list, remove duplicates such that each element only exists once.


Maintain two pointers, prev and curr, whiling walking the list. If curr’s value is equal to prev’s value, remove curr. 16 more words

Designing a data structure (in this case the list)

Before you start designing your data structure it is a good idea to first stop and think about what you want to use it for. If you require a simple structure to store your data before applying a function to each element of data (also called… 1,632 more words

Data Structures And Algorithms

LRU/LFU/Expire Timestamp Cache

LRU Cache

Implement get and set API for a LRU cache.

Use doubly linked list + hash map to solve. Hash map stores key to node mapping. 377 more words