Data Structures
Data Structures help in elegant representation of data for algorithms
Arrays
Name | Preview | Code | Difficulty |
---|---|---|---|
Arrays - DS | Accessing and using arrays. | C++ Python | Easy |
2D Array - DS | How to access and use 2d-arrays. | Python | Easy |
Dynamic Array | Learn to use dynamic arrays by solving this problem. | Python | Easy |
Left Rotation | Given an array and a number, d, perform d left rotations on the array. | Python | Easy |
Sparse Arrays | Determine the number of times a string has previously appeared. | Python | Medium |
Array Manipulation | Perform m operations on an array and print the maximum of the values. | Python | Hard |
Linked Lists
Name | Preview | Code | Difficulty |
---|---|---|---|
Print the Elements of a Linked List | Get started with Linked Lists! | C++ | Easy |
Insert a Node at the Tail of a Linked List | Create and insert a new node at the tail of a linked list. | C++ | Easy |
Insert a node at the head of a linked list | Create and insert a new node at the head of a linked list | C++ | Easy |
Insert a node at a specific position in a linked list | Insert a node at a specific position in a linked list. | C++ | Easy |
Delete a Node | Delete a node from the linked list and return the head. | C++ | Easy |
Print in Reverse | Print the elements of a linked list in reverse order, from tail to head | C++ | Easy |
Reverse a linked list | Change the links between the nodes of a linked list to reverse it | C++ | Easy |
Compare two linked lists | Compare the data in two linked lists node by node to see if the lists contain identical data. | C++ | Easy |
Merge two sorted linked lists | Given the heads of two sorted linked lists, change their links to get a single, sorted linked list. | C++ | Easy |
Get Node Value | Given the head of a linked list, get the value of the node at a given position when counting backwards from the tail. | Python | Easy |
Delete duplicate-value nodes from a sorted linked list | Given a linked list whose nodes have data in ascending order, delete some nodes so that no value occurs more than once. | C++ | Easy |
Cycle Detection | Given a pointer to the head of a linked list, determine whether the linked list loops back onto itself | C++ | Medium |
Find Merge Point of Two Lists | Given two linked lists, find the node where they merge into one. | C++ | Easy |
Inserting a Node Into a Sorted Doubly Linked List | Create a node with a given value and insert it into a sorted doubly-linked list | C++ | Easy |
Reverse a doubly linked list | Given the head node of a doubly linked list, reverse it. | Python | Easy |
Trees
Name | Preview | Code | Difficulty |
---|---|---|---|
Tree: Preorder Traversal | Print the preorder traversal of a binary tree. | C++ | Easy |
Tree: Postorder Traversal | Print the post order traversal of a binary tree. | C++ | Easy |
Tree: Inorder Traversal | Print the inorder traversal of a binary tree. | C++ | Easy |
Tree: Height of a Binary Tree | Given a binary tree, print its height. | C++ Python | Easy |
Tree : Top View | Given a binary tree, print it’s top view. | C++ | Easy |
Tree: Level Order Traversal | Level order traversal of a binary tree. | C++ | Easy |
Binary Search Tree : Insertion | Given a number, insert it into it’s position in a binary search tree. | C++ | Easy |
Tree: Huffman Decoding | Given a Huffman tree and an encoded binary string, you have to print the original string. | C++ | Medium |
Binary Search Tree : Lowest Common Ancestor | Given two nodes of a binary search tree, find the lowest common ancestor of these two nodes. | C++ | Easy |
Array Pairs | Count the number of pairs satisfying a condition. | Python | Advanced |
Stacks
Name | Preview | Code | Difficulty |
---|---|---|---|
Maximum Element | Given three types of queries, insert an element, delete an element or find the maximum element in a stack. | C++ | Easy |
Balanced Brackets | Given a string containing three types of brackets, determine if it is balanced. | Python | Medium |
Equal Stacks | Equalize the piles! | Python | Easy |
Largest Rectangle | Given n buildings, find the largest rectangular area possible by joining consecutive K buildings. | Python | Medium |
Simple Text Editor | Implement a simple text editor and perform some number of operations. | Python | Medium |
Queues
Name | Preview | Code | Difficulty |
---|---|---|---|
Queue using Two Stacks | Create a queue data structure using two stacks. | Python | Medium |
Heap
Name | Preview | Code | Difficulty |
---|---|---|---|
QHEAP1 | Solve the basic heap question with insertion and deletion. | Python | Easy |
Jesse and Cookies | Calculate the number of operations needed to increase the sweetness of the cookies so that each cookie in the collection has a sweetness >=K. | Python | Easy |
Find the Running Median | Find the median of the elements after inputting each element. | Python | Hard |
Trie
Name | Preview | Code | Difficulty |
---|---|---|---|
Contacts | Create a Contacts application with the two basic operations: add and find. | Python | Medium |
No Prefix Set | Given N strings, find if a string is a prefix of another string. | Python | Hard |