https://github.com/anishlearnstocode/hackerrank-data-structures
Data Structures 👩💻 Domain on HackerRank - Problems & Solutions 📑📘
https://github.com/anishlearnstocode/hackerrank-data-structures
algorithms arrays balanced-trees data-structures disjoint-set graph hackerrank hackerrank-data-structures hackerrank-solutions heap java linked-lists online-judge queues reference solutions stacks trees trie
Last synced: 2 months ago
JSON representation
Data Structures 👩💻 Domain on HackerRank - Problems & Solutions 📑📘
- Host: GitHub
- URL: https://github.com/anishlearnstocode/hackerrank-data-structures
- Owner: anishLearnsToCode
- License: mit
- Created: 2018-05-20T15:35:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-03T18:47:48.000Z (over 4 years ago)
- Last Synced: 2025-04-10T22:11:24.184Z (6 months ago)
- Topics: algorithms, arrays, balanced-trees, data-structures, disjoint-set, graph, hackerrank, hackerrank-data-structures, hackerrank-solutions, heap, java, linked-lists, online-judge, queues, reference, solutions, stacks, trees, trie
- Language: Java
- Homepage: https://www.hackerrank.com/domains/data-structures
- Size: 341 KB
- Stars: 22
- Watchers: 1
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# HackerRank Data Structures Solutions





[](CONTRIBUTING.md)
[](https://github.com/anishLearnsToCode/competitive-programming)
[](https://www.hackerrank.com/anishviewer)This repository contains solutions to the
[Data Structures domain](https://www.hackerrank.com/domains/data-structures) part of HackerRank.
The Data Structures Domain Falls under a broader Problem Solving Skill Set in HackerRank
which consists of both
[Data Structures](https://www.hackerrank.com/domains/data-structures)
and [Algorithms](https://www.hackerrank.com/domains/algorithms).The Data Structures Domain is further Divided into the following sub-domains.
To Contribute have a look at
[Contributing.md](Contributing.md)
and happy coding 😀 🐱💻.## Sub Domains & Problems (+Solutions) in the Data Structures Domain
⚡ Quick Links:
[Arrays](#arrays-) |
[Linked Lists](#linked-lists-) |
[Trees](#trees-) |
[Balanced Trees](#balanced-trees-) |
[Stacks](#stacks-) |
[Queues](#queues-) |
[Heap](#heap-) |
[Disjoint Set](#disjoint-set-) |
[Multiple Choice](#multiple-choice-) |
[Trie](#trie-) |
[Advanced](#advanced-) |
### Arrays | Problem | Difficulty Level | Solution Link |
|---------|------------------|:-------------:|
| [Arrays - DS](https://www.hackerrank.com/challenges/arrays-ds) | Easy | [](src/arrays/ArraysDS.java) |
| [2D Arrays - DS](https://www.hackerrank.com/challenges/2d-array) | Easy | [](src/arrays/TwoDArrays.java) |
| [Dynamic Array](https://www.hackerrank.com/challenges/dynamic-array) | Easy | [](src/arrays/DynamicArray.java) |
| [Left Rotation](https://www.hackerrank.com/challenges/array-left-rotation) | Easy | [](src/arrays/LeftRotation.java) |
| [Sparse Arrays](https://www.hackerrank.com/challenges/arrays-ds) | Medium | [](src/arrays/SparseArrays.java) |
| [Array Manipulation](https://www.hackerrank.com/challenges/crush) | Hard | [](src/arrays/ArrayManipulation.java) |### Linked Lists 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|:-------------:|
| [Print the Elements of a Linked List](https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list) | Easy | [](src/linkedlist/PrintElementsOfLinkedList.java) |
| [Insert a Node at the Tail of a Linked List](https://www.hackerrank.com/challenges/insert-a-node-at-the-tail-of-a-linked-list) | Easy | [](src/linkedlist/InsertNodeAtTailOfLinkedList.java) |
| [Insert a Node at the head of a Linked List](https://www.hackerrank.com/challenges/insert-a-node-at-the-head-of-a-linked-list) | Easy | [](src/linkedlist/InsertNodeAtHeadOfLinkedList.java) |
| [Insert a Node at a specific position in a Linked List](https://www.hackerrank.com/challenges/insert-a-node-at-a-specific-position-in-a-linked-list) | Easy | [](src/linkedlist/InsertNodeAtSpecificPosition.java) |
| [Delete a Node](https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list) | Easy | [](src/linkedlist/DeleteANode.java) |
| [Print in Reverse](https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list-in-reverse) | Easy | [](src/linkedlist/PrintInReverse.java) |
| [Reverse a Linked List](https://www.hackerrank.com/challenges/reverse-a-linked-list) | Easy | [](src/linkedlist/ReverseALinkedList.java) |
| [Compare two Linked Lists](https://www.hackerrank.com/challenges/compare-two-linked-lists) | Easy | [](src/linkedlist/Compare2LinkedList.java) |
| [Merge two sorted Linked Lists](https://www.hackerrank.com/challenges/merge-two-sorted-linked-lists) | Easy | [](src/linkedlist/Merge2SortedLinkedList.java) |
| [Get Node Value](https://www.hackerrank.com/challenges/get-the-value-of-the-node-at-a-specific-position-from-the-tail) | Easy | [](src/linkedlist/GetNodeValue.java) |
| [Delete Duplicate Value Nodes from a sorted Linked List](https://www.hackerrank.com/challenges/delete-duplicate-value-nodes-from-a-sorted-linked-list) | Easy | [](src/linkedlist/DeleteDuplicateValueNodesFromSortedLinkedList.java) |
| [Cycle Detection](https://www.hackerrank.com/challenges/detect-whether-a-linked-list-contains-a-cycle) | Medium | [](src/linkedlist/CycleDetection.java) |
| [Find Merge Points of Two Lists](https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists) | Easy | [](src/linkedlist/FindMergePointOf2Lists.java) |
| [Inserting a Node Into a Sorted Double Linked List](https://www.hackerrank.com/challenges/insert-a-node-into-a-sorted-doubly-linked-list) | Easy | [](src/linkedlist/InsertANodeInSortedDoublyLinkedList.java) |
| [Reverse a Doubly Linked List](https://www.hackerrank.com/challenges/reverse-a-doubly-linked-list) | Easy | [](src/linkedlist/ReverseDoublyLinkedList.java) |### Trees 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|:-------------:|
| [Tree: Preorder Traversal](https://www.hackerrank.com/challenges/tree-preorder-traversal) | Easy | [](src/trees/PreorderTraversal.java) |
| [Tree: Postorder Traversal](https://www.hackerrank.com/challenges/tree-postorder-traversal) | Easy | [](src/trees/PostOrderTraversal.java) |
| [Tree: Inorder Traversal](https://www.hackerrank.com/challenges/tree-inorder-traversal) | Easy | [](src/trees/InorderTraversal.java) |
| [Tree: Height of Binary Tree](https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree) | Easy | [](src/trees/HeightOfBinaryTree.java) |
| [Tree: Level Order Traversal](https://www.hackerrank.com/challenges/tree-level-order-traversal) | Easy | [](src/trees/LevelOrderTraversal.java) |
| [Binary Search Tree: Insertion](https://www.hackerrank.com/challenges/binary-search-tree-insertion) | Easy | [](src/trees/BST_Insertion.java) |
| [Tree: Huffman Decoding](https://www.hackerrank.com/challenges/tree-huffman-decoding) | Medium | [](src/trees/TreeHuffmanDecoding.java) |
| [Binary Search Tree: Lowest Common Ancestor](https://www.hackerrank.com/challenges/binary-search-tree-lowest-common-ancestor) | Easy | [](src/trees/LowestCommonAncestor.java) |
| [Swap Nodes [Algo]](https://www.hackerrank.com/challenges/swap-nodes-algo) | Medium | [](src/trees/SwapNodes_Algo.java) |
| [Is There a Binary Search Tree](https://www.hackerrank.com/challenges/is-binary-search-tree) | Medium | [](src/trees/IsThisBinarySearchTree.java) |
| [Tree: Top View](https://www.hackerrank.com/challenges/tree-top-view) | Easy | [](src/trees/TreesTopView.java) |
| [Kitty's Calculations on a Tree](https://www.hackerrank.com/challenges/kittys-calculations-on-a-tree) | Advanced | [](src/trees/KitysCalculationOnATree.cpp) |
| [Square Ten Tree](https://www.hackerrank.com/challenges/square-ten-tree) | Hard |[](src/trees/SquareTenTree.cpp) |
| [Balanced Forest](https://www.hackerrank.com/challenges/balanced-forest) | Hard | [](python/trees/balanced-forest.py) |
| [Jenny's Subtrees](https://www.hackerrank.com/challenges/jenny-subtrees) | Hard | |
| [Tree Coordinates](https://www.hackerrank.com/challenges/tree-coordinates) | Expert | |
| [Array Pairs](https://www.hackerrank.com/challenges/array-pairs) | Advanced | |### Balanced Trees 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|---------------|
| [Self Balancing Tree](https://www.hackerrank.com/challenges/self-balancing-tree) | Medium | |
| [Array and Simple Queries](https://www.hackerrank.com/challenges/array-and-simple-queries) | Hard | |
| [Median Updates](https://www.hackerrank.com/challenges/median) | Hard | |### Stacks 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|:-------------:|
| [Maximum Element](https://www.hackerrank.com/challenges/maximum-element) | Easy | [](src/stacks/MaximumElement.java) |
| [Balanced Brackets](https://www.hackerrank.com/challenges/balanced-brackets) | Medium | [](src/stacks/BalancedBrackets.java) |
| [Equal Stacks](https://www.hackerrank.com/challenges/equal-stacks) | Easy | [](src/stacks/EqualStacks.java) |
| [Game of Two Stacks](https://www.hackerrank.com/challenges/game-of-two-stacks) | Medium | [](src/stacks/GameOfTwoStacks.java) |
| [Simple Text Editor](https://www.hackerrank.com/challenges/simple-text-editor) | Medium | [](src/stacks/SimpleTextEditor.java) |
| [Waiter](https://www.hackerrank.com/challenges/waiter) | Medium | [](src/stacks/Waiter.java) |
| [Largest Rectangle](https://www.hackerrank.com/challenges/largest-rectangle) | Medium | [](src/stacks/LargestRectangle.java) [](python/stacks/largest-rectangle.py) |
| [Poisonous Plants](https://www.hackerrank.com/challenges/poisonous-plants) | Hard | [](src/stacks/PoisonousPlants.java) |
| [AND xor OR](https://www.hackerrank.com/challenges/and-xor-or) | Hard | |### Queues 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|---------------|
| [Queue Using Two Stacks](https://www.hackerrank.com/challenges/queue-using-two-stacks) | Medium | [](src/queues/QueueUsingTwoStacks.java) |
| [Castle on The Grid](https://www.hackerrank.com/challenges/castle-on-the-grid) | Medium | [](src/queues/CastleOnTheGrid.java) |
| [Down to Zero II](https://www.hackerrank.com/challenges/down-to-zero-ii) | Medium | [](src/queues/DownToZeroII.java) |
| [Truck Tour](https://www.hackerrank.com/challenges/truck-tour) | Hard | [](src/queues/TruckTourProblem.java) |
| [Queries with Fixed Length](https://www.hackerrank.com/challenges/queries-with-fixed-length) | Hard | [](src/queues/QueriesWithFixedLength.java) |### Heap 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|---------------|
| [QHEAP1](https://www.hackerrank.com/challenges/qheap1) | Easy | [](src/heap/QHEAP1.java) |
| [Jessie and Cookies](https://www.hackerrank.com/challenges/jesse-and-cookies) | Easy | [](src/heap/JesseAndCookies.java) |
| [Find the Running Median](https://www.hackerrank.com/challenges/find-the-running-median) | Hard | [](src/heap/FindTheRunningMedian.java) |
| [Minimum Average Wait Time](https://www.hackerrank.com/challenges/minimum-average-waiting-time) | Hard | [](python/heap/minimum-average-waiting-time.py) |### Disjoint Set 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|---------------|
| [Components In A Graph](https://www.hackerrank.com/challenges/components-in-graph) | Medium | [](src/disjoint_set/ComponentsInAGraph.java) |
| [Kundu and Tree](https://www.hackerrank.com/challenges/kundu-and-tree) | Hard | |
| [Super Maximum Cost Queries](https://www.hackerrank.com/challenges/maximum-cost-queries) | Hard | |
| [Merging Communities](https://www.hackerrank.com/challenges/merging-communities) | Hard | |### Multiple Choice 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|:-------------:|
| [Data Structures MCQ1](https://www.hackerrank.com/challenges/how-well-do-you-know-trees) | Multiple Choice Question | [](src/mcq/Data%20Structure%20MCQ%201.md) |
| [Data Structures MCQ2](https://www.hackerrank.com/challenges/are-you-an-expert-on-data-structures) | Multiple Choice Question | [](src/mcq/Data%20Structure%20MCQ%202.md) |
| [Data Structures MCQ3](https://www.hackerrank.com/challenges/are-you-an-expert-on-data-structures-1) | Multiple Choice Question | [](src/mcq/Data%20Structure%20MCQ%203.md) |### Trie 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|:-------------:|
| [Contacts]() | Medium | [](src/trie/Contacts.java) |
| [No Prefix Set](https://www.hackerrank.com/challenges/no-prefix-set) | Hard | |### Advanced 
| Problem | Difficulty Level | Solution Link |
|---------|------------------|---------------|
| [Kindergarten Adventures](https://www.hackerrank.com/challenges/kindergarten-adventures) | Medium | |
| [Mr. X and his Shots](https://www.hackerrank.com/challenges/x-and-his-shots) | Medium | |
| [Cube Summation](https://www.hackerrank.com/challenges/cube-summation) | Hard | |
| [Direct Connections](https://www.hackerrank.com/challenges/direct-connections) | Hard | |
| [Subsequence Weighting](https://www.hackerrank.com/challenges/subsequence-weighting) | Advanced | |
| [Jim and the Skyscrapers](https://www.hackerrank.com/challenges/jim-and-the-skyscrapers) | Medium | |
| [Palindromic Subsets](https://www.hackerrank.com/challenges/palindromic-subsets) | Hard | |
| [Counting On A Tree](https://www.hackerrank.com/challenges/counting-on-a-tree) | Expert | |
| [Polynomial Division](https://www.hackerrank.com/challenges/polynomial-division) | Hard |
| [Costly Intervals](https://www.hackerrank.com/challenges/costly-intervals) | Hard |
| [The Strange Function](https://www.hackerrank.com/challenges/the-strange-function) | Hard |
| [Self-Driving Bus](https://www.hackerrank.com/challenges/self-driving-bus) | Advanced |
| [Unique Colors](https://www.hackerrank.com/challenges/unique-colors) | Advanced |
| [Fibonacci Numbers Tree](https://www.hackerrank.com/challenges/fibonacci-numbers-tree) | Expert |
| [Pair Sums](https://www.hackerrank.com/challenges/pair-sums) | Expert |
| [Functional Palindromes](https://www.hackerrank.com/challenges/functional-palindromes) | Advanced |
| [Lazy White Falcon](https://www.hackerrank.com/challenges/lazy-white-falcon) | Hard |
| [Ticket To Ride](https://www.hackerrank.com/challenges/ticket-to-ride) | Expert |
| [Heavy Light White Falcon](https://www.hackerrank.com/challenges/heavy-light-white-falcon) | Hard |
| [Sum of The Maximums](https://www.hackerrank.com/challenges/little-alexey-and-sum-of-maximums) | Advanced |
| [Number Game On A Tree](https://www.hackerrank.com/challenges/number-game-on-a-tree) | Expert |
| [Heavy Light 2 White Falcon](https://www.hackerrank.com/challenges/heavy-light-2-white-falcon) | Hard |
| [Library Query](https://www.hackerrank.com/challenges/library-query) | Advanced |
| [Starfleet](https://www.hackerrank.com/challenges/starfleet) | Advanced |
| [Almost Equal - Advanced](https://www.hackerrank.com/challenges/almost-equal-advanced) | Expert |
| [Almost Sorted Interval](https://www.hackerrank.com/challenges/almost-sorted-interval) | Expert |
| [Burger Happiness](https://www.hackerrank.com/challenges/burger-happiness) | Hard |
| [Roy and Alpha Beta Trees](https://www.hackerrank.com/challenges/roy-and-alpha-beta-trees) | Hard |
| [Coloring Tree](https://www.hackerrank.com/challenges/coloring-tree) | Hard |
| [Recalling Early Days GP With Trees](https://www.hackerrank.com/challenges/recalling-early-days-gp-with-trees) | Hard |
| [Swaps and Sums](https://www.hackerrank.com/challenges/swaps-and-sum) | Advanced |
| [Arithmetic Progressions](https://www.hackerrank.com/challenges/arithmetic-progressions) | Advanced |
| [Coolguy And Two Subsequences](https://www.hackerrank.com/challenges/coolguy-and-two-subsequences) | Advanced |
| [White Falcon and Tree](https://www.hackerrank.com/challenges/white-falcon-and-tree) | Hard |
| [Subtrees and Paths](https://www.hackerrank.com/challenges/subtrees-and-paths) | Advanced |
| [Triplets](https://www.hackerrank.com/challenges/triplets) | Advanced |
| [Beautiful Segments](https://www.hackerrank.com/challenges/beautiful-segments) | Expert | |
| [Divisibility](https://www.hackerrank.com/challenges/ab0) | Expert |
| [BST Maintenance](https://www.hackerrank.com/challenges/bst-maintenance) | Advanced |
| [Find Maximum Index Product](https://www.hackerrank.com/challenges/find-maximum-index-product) | Medium |
| [Taxicab Driver's Problem](https://www.hackerrank.com/challenges/taxicab-drivers-problem) | Advanced |
| [Jaggu Playing With Balloons](https://www.hackerrank.com/challenges/jagia-playing-with-numbers) | Advanced |
| [Dynamic Summation](https://www.hackerrank.com/challenges/dynamic-summation) | Hard |
| [Two Array Problem](https://www.hackerrank.com/challenges/weird-queries) | Hard | |
| [Rooted Tree](https://www.hackerrank.com/challenges/rooted-tree) | Hard | |
| [The Crazy Helix](https://www.hackerrank.com/challenges/helix) | Advanced | |
| [Network Administration](https://www.hackerrank.com/challenges/net-admin) | Hard | |
| [Easy Addition](https://www.hackerrank.com/challenges/easy-addition) | Expert | |
| [Find The Permutation]() | Expert | |
| [Company Retreat](https://www.hackerrank.com/challenges/company-retreat) | Advanced | |
| [Box Operations](https://www.hackerrank.com/challenges/box-operations) | Expert | |
| [Max Transform](https://www.hackerrank.com/challenges/max-transform) | Expert | |
| [Array and Queries](https://www.hackerrank.com/challenges/array-and-queries-1) | Hard | |