educative.io

Coderust: Hacking the Coding Interview (Coderust)


Trees - In-order Successor Binary Search Tree With Parent Pointers The in-order successor of a node in a binary tree is the next node in an in-order traversal. Write a method to find an in-order successor of a given binary tree node in a binary search tree given parent pointers. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lYOPg). Arrays - Find Maximum in Sliding Window Given an array of integers, find the maximum value in a window. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k5llE). Arrays - Find the Smallest Common Number Given three integer arrays sorted in ascending order, return the smallest number that is common in all three arrays. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lR76). Trees - Check if Two Binary Trees are Identical Given the roots of two binary trees, determine if these trees are identical or not. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mZkl0). Linked List - Reverse Alternate K Nodes in a Singly Linked List Given a singly linked list and an integer 'k', reverse every 'k' element. If k <= 1, then the input list is unchanged. If k >= n (n is the length of linked list), then reverse the whole linked list. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/nZwM4). Math & Stats - Find Missing Number Given an array of positive numbers from 1 to n, such that all numbers from 1 to n are present except one; find the missing number. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kR5PN). Trees - Is a Binary Search Tree Valid? Given a binary tree, figure out whether it's a BST. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jqBDy). Arrays - Sort an Array Using Quicksort Algorithm Given an integer array, sort it in ascending order using quicksort. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lO82M). Arrays - Find Pair With Given Sum in an Array Given an array of integers and a value, determine if there are any two integers in the array whose sum is equal to the given value. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jv314). Linked List - Reverse a Singly Linked List Reverse the singly linked list and return the pointer/reference to the head of the reversed linked list. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lq2j). Arrays - Stock Buy Sell to Maximize Profit Given a list of stock prices for n days, find the maximum profit with a single buy or sell activity. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/j2pGW). Back Tracking - Solve N-Queens Problem Find how many ways can N-queens be placed on a chessboard so the queens do not attack each other. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/j2WmR). Back Tracking - Find K-Sum Subsets Given an array of positive integers, find all the subsets of the given array that sum up to a number K. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kRg9X). Trees - Iterative In-Order Traversal of Binary Tree Write an in-order traversal of a binary tree iteratively. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mZlv3). Appendix - Other Resources List of other resources that you can use to prepare for programming interviews. Strings - XML to Tree Convert an XML string to an n-ary tree. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lYoXJ). Math & Stats - Is String a Valid Number? Given an input string, determine if it makes a valid number or not. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jvzXy). Strings - Remove White Spaces from a String Given a null terminated string, remove any white spaces (tabs or spaces). View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mqy0). Math & Stats - Integer Division Without Using * or / Divide two integers without using '/' (division) or '*' (multiplication) operators. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/j2ZGy). Dynamic Programming - Largest Sum Subarray Given an array, find the contiguous subarray with the largest sum. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kWpK). Appendix - Frequently Asked Questions FAQs for Codersut 3.0. Graphs - Minimum Spanning Tree Find the minimum spanning tree of a connected, undirected graph with weighted edges. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/j2rp5). Stacks and Queues - Implement Stack Using Queues Implement a stack using queues. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jq25Y). Miscellaneous - Determine Host Byte Order (Endianness) Determine the host byte order (endianness). View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jAZvP). Appendix - Testimonials Have questions about Appendix - Testimonials? Go for it! Graphs - Word Chaining Figure out whether the given words can form a circular chain. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k27X). Arrays - Merge an Array With Overlapping Intervals Merge overlapping intervals in an array of interval pairs. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lY7or). Strings - Word Break Problem Given a dictionary of words and an input string tell whether the input string can be completely segmented into dictionary words. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mZypr). Trees - Connect Same Level Siblings of a Binary Tree Given a binary tree, connect its siblings at each level. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k5z2Y). Dynamic Programming - MaxSum Subsequence - Nonadjacent Elements Find the maximum sum of a subsequence made up of nonadjacent elements in an array. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kRnBY). Linked List - Delete All Occurrences of a Given Key in a Linked List Given the head of a linked list and a key, delete the node with this given key from the linked list. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mBNG). Trees - Delete Zero Sum Sub-Trees Delete any subtrees whose nodes sum up to zero for a given binary tree. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mwvLp). Dynamic Programming - Coin Changing Problem Given coin denominations and the total amount, find the number​ of ways to make the change. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/j2kkl). Miscellaneous - Implement LRU Cache Implement a Least Recently Used (LRU) Cache. Discuss data structures involved. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jRLoR). Linked List - Intersection Point of Two Lists Given the head nodes of two linked lists that may or may not intersect, find out if they intersect and return the point of intersection. Return null otherwise. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/nvO5). Strings - Remove Duplicates from a String Remove duplicate characters from a string which is passed by reference. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kRYnK). Trees - Print Tree Perimeter This lesson contains a challenge and its solution for finding the perimeter of a tree. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/nROl). Dynamic Programming - Fibonacci Numbers Find the nth Fibonacci number in the Fibonacci sequence. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lAEM). Trees - Connect All Siblings of a Binary Tree Connect the sibling pointer to the next node in the same level. The last node in each level should point to the first node of the next level in the tree. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jq8kB). Stacks and Queues - Evaluate Arithmetic Expressions Given a string of arithmetic expression, evaluate its result. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/l6PJ). Linked List - Remove Duplicates from a Linked List Remove duplicate nodes from a linked list of integers while keeping only the first occurrence of duplicates. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lYZoV). Linked List - Sort Linked List Using Insertion Sort Given the head pointer of a linked list, sort it in ascending order using insertion sort. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kZDkv). Math & Stats - Pythagorean Triplets Given an integer array, find all Pythagorean triplets. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jRK0W). Miscellaneous - Sum of Three Values Given an array of integers and a value, determine if there are any three integers in the array whose sum equals the given value. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k6Xx). Dynamic Programming - Levenshtein Distance Compute the Levenshtein distance between two strings. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/j2A0v). Math & Stats - Calculate Power of a Number Given a double, 'x', and an integer, 'n', write a function to calculate 'x' raised to the power 'n'. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jR7p4). Math & Stats - Find All Subsets of a Set Find all subsets of a given set of integers. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jRlPY). Strings - Find all Palindrome Substrings Given a string, find all substrings that are palindromes. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mZp8A). Strings - Regular Expression Matching in String Given a text and a pattern, evaluate the pattern to see if it matches with the text by using regular expression matching. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lOrKl). Linked List - Copy Linked List with Arbitrary Pointer Make a deep copy of the given linked list where each node has two pointers: 'next' and 'arbitrary_pointer'. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mZjYp). Trees - Level Order Traversal of Binary Tree Given the root of a binary tree, display the node values at each level. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lYjr1). Linked List - Sort a Linked List Using Merge Sort Given the head pointer of a linked sort, sort the linked list in ascending order using merge sort, and return the new head pointer of sorted linked list. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kl4r). Dynamic Programming - Find Combinations for Game Scoring Find the number of ways a player can score 'n' runs. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/j2J5P). Linked List - Reverse Even Nodes in a Linked List Given a singly linked list, reverse the nodes at even indices. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lOxKj). Arrays - Rotate an Array by N Elements Given an array of integers, rotate the array by 'N' elements. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lOmmr). Math & Stats - Print All Permutations of a String Implement a method to print all permutations of a given string without duplicates. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kzX6). Linked List - Find n'th Node from the End of a Linked List Given a singly linked list, return the nth from last node. Return null if 'n' is out-of-bounds. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mryR). Trees - Write an In-Order Iterator for a Binary Tree Implement a class that implements an in-order iterator on a Binary Tree. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/o2r8N). Miscellaneous - Search in a Matrix Search, or find the position of, a given key in a 2D matrix. All rows and columns are sorted. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jR8ml). Trees - Mirror Binary Tree Nodes Given the root node of a binary tree, swap the 'left' and 'right' children for each node. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jv72v). Trees - Serialize/Deserialize Binary Tree Serialize a binary tree to a file and then deserialize it back to a tree so that the original and the deserialized trees are identical. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k5vqX). Strings - Reverse Words in a Sentence Given a sentence (an array of characters), reverse the order of words. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/j2yYz). Miscellaneous - Make Columns and Rows Zeros Given a two-dimensional array, if any element within is zero, make its whole row and column zero. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k56r6). Arrays - Find Low/High Index of a Key in a Sorted Array Given a sorted array of integers, return the low and high index of the given key. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lYg2l). Linked List - Add Two Integers Represented by Linked Lists Given the head pointers of two linked lists where each linked list represents an integer number (each node is a digit), add them and return the resulting linked list. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/n5kg4). Arrays - Move All Zeros to the Beginning of the Array Move all zeros to the left of an array while maintaining its order. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k58JJ). Linked List - Rotate a Linked List Given the head node of a singly linked list and an integer 'n', rotate the linked list by 'n'. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kRmPr). Trees - Nth Highest Number in Binary Search Tree Find the nth highest node in a Binary Search Tree(BST). View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mw7YG). Stacks and Queues - Implement Queue Using Stacks Implement a queue using stacks. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k5Wn5). Math & Stats - Find kth Permutation Given a set of n elements, find their kth permutation. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jRm5z). Miscellaneous - Closest Meeting Point Given N people on an MxM grid, find the point that requires the least total distance covered by all people to meet at that point. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jRB75). Trees - In-order Successor of Binary Search Tree This lesson will contain a challenge to find the in-order successor. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lOWo5). Arrays - Implement Binary Search on a Sorted Array Given a sorted array of integers, return the index of the given key. Return -1 if the key is not found. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k5qJx). Math & Stats - Calculate Square Root of a Number Given a double number, write a function to calculate its square root. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kRLrx). Arrays - Search a Rotated Array Search for a given number in a sorted array that has been rotated by some arbitrary number. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kR7nE). Back Tracking - Boggle Given an NxN grid of characters and a dictionary, find all words which can be made from the characters in the grid, which are present in the given dictionary. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/kR9qv). Trees - Convert N-ary Tree to Binary Tree Convert an N-ary tree to a Binary tree and then reconvert it to its original N-ary tree structure. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jvj9B). Linked List - Implementation of Linked List Linked list implementation will be covered in this lesson. We'll use this implementation in the whole chapter. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/g2o7XQv44z9). Linked List - Merge Two Sorted Linked Lists Given two sorted linked lists, merge them so that the resulting linked list is also sorted. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/mZ1pn). Trees - Convert Binary Tree to Doubly Linked List Given a binary tree, convert it to a doubly linked list so that the order of the doubly linked list is the same as an in-order traversal of the binary tree. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/n5q7D). Back Tracking - Print All Combinations of Balanced Braces Print all balanced braces combinations for a given value 'n'. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/jRXmB). Trees - Implementation of Binary Tree Binary Tree implementation will be covered in this lesson. We'll use this implementation in the whole chapter. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/g2DQOknrJWl). Graphs - Clone a Directed Graph Given the root node of a directed graph, clone this graph by creating its deep copy so that the cloned graph has the same vertices and edges as the original graph. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lWqV). Linked List - Swap Nth Node with Head Given the head of a singly linked list and 'N', swap the head with the Nth node. Return the head of the new linked list. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/k5MBN). Math & Stats - All Possible Combinations for a Given Sum Given a positive integer, return all possible sum combinations for this number using positive integers. View the lesson [here](https://www.educative.io/courses/coderust-hacking-the-coding-interview/lY0j6).
About the Coderust: Hacking the Coding Interview (Coderust) category [Coderust: Hacking the Coding Interview (Coderust)] (1)
Why store the index as list in linkedList and store the result in arrayDeque? [Arrays - Find Maximum in Sliding Window] (1)
Trees-Print Tree Perimeter [Trees - Print Tree Perimeter] (4)
Word Brea solution with memoization [Strings - Word Break Problem] (2)
Where is code for these classes : LinkedList & LinkedListNode ? I can not find "create_linked_list" method? [Linked List - Remove Duplicates from a Linked List] (4)
Where is the LinkedListNode and LinkedList code man? [Linked List - Sort Linked List Using Insertion Sort] (2)
One-pass solution [Trees - Print Tree Perimeter] (1)
Iterative solution [Trees - Is a Binary Search Tree Valid?] (1)
More Pythonic way [Trees - Iterative In-Order Traversal of Binary Tree] (1)
More classic recursion approach [Strings - Word Break Problem] (1)
What is the benefit of the advised solution over a simple loop? [Math & Stats - Calculate Power of a Number] (2)
Shorter solution in Python, works on lists with any elements [Math & Stats - Find kth Permutation] (1)
Solution using Python chain comparisons [Arrays - Search a Rotated Array] (1)
Improved Solution [Arrays - Search a Rotated Array] (1)
Simplified Solution [Arrays - Stock Buy Sell to Maximize Profit] (1)
Provided solution is not the most optimal [Arrays - Find the Smallest Common Number] (2)
Not O(1) implemenation [Miscellaneous - Implement LRU Cache] (1)
Incorrect test case [Math & Stats - Is String a Valid Number?] (2)
BinaryTree & BinaryTreeNode [Trees - Check if Two Binary Trees are Identical] (3)
Python Solution [Graphs - Minimum Spanning Tree] (1)
Boggle: Runtime complexity [Back Tracking - Boggle] (1)
Confused on coin when amount i 6 [Dynamic Programming - Coin Changing Problem] (2)
How did we arrive at the recurrence relation shown in the solution [Dynamic Programming - Find Combinations for Game Scoring] (1)
Test does take into account the order in the output though it shouldn't [Back Tracking - Find K-Sum Subsets] (1)
Why time complexity is O(2^n) not O(2^n * n)? [Math & Stats - Find All Subsets of a Set] (3)
Definition of head is different from the data structure course? [Linked List - Reverse a Singly Linked List] (5)
Avoid global variable [Trees - Nth Highest Number in Binary Search Tree] (2)
Unclear example [Linked List - Reverse Even Nodes in a Linked List] (2)
Strange signature for Java [Math & Stats - All Possible Combinations for a Given Sum] (2)
Problem with solution [Math & Stats - Integer Division Without Using * or /] (2)