Category: data structure
A queue is a first-in-first-out (FIFO) data structure. We all know that the list/array in Python is very powerful, that it can be used as a queue itself. For …
A stack is a first-in-last-out (FILO) data structure. We all know that the list/array in Python is very powerful, that it can be used as a stack itself. For …
Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example …
There are N cities numbered from 1 to N. You are given connections, where each connections = represents the cost to connect city1 and city2 together. (A connection is …
You have some sticks with positive integer lengths. You can connect any two sticks of lengths X and Y into one stick by paying a cost of X + …