Course
DSA Sheet
27 lessons51 min total
-
Sentence or String Reversal in Python
Given a string of words, reverse all the words. For example:
-
Array Pair Sum in Python
Given an integer array, output all the unique pairs that sum up to a specific value k.
-
Find the Missing Element in Python
Consider an array of non-negative integers. A second array is formed by shuffling the elements of the first…
-
Largest Continuous Sum in Python
Given an array of integers (positive and negative) find the largest continuous sum.
-
String Compression in Python
Given a string in the form 'AAAABBBBCCCCCDDEEEE' compress it to become 'A4B4C5D2E4'. For this problem, you can falsely…
-
Unique Characters in String using Python
Given a string,determine if it is compressed of all unique characters. For example, the string 'abcde' has all…
-
Balanced Parentheses Check in Python
Given a string of opening and closing parentheses, check whether it’s balanced. We have 3 types of parentheses:…
-
Problems based on bit manipulation
In the previous topic, we got an introduction to Bit Manipulation in DSA. Let us now look at…
-
Build Array From Permutation
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]]…
-
Square Root of Integer
Given an integer A. Compute and return the square root of A. If A is not a perfect…
-
Product of Array Except Self
Problem Statement (Asked By Uber) Given a list of integers, return a new list such that each element…
-
Serialize and Deserialize a Binary Tree
Given the root of a binary tree, create two functions: serialize(root) – Converts the binary tree into a…
-
Find the Smallest Missing Positive Integer
Problem Statement (Asked By Stripe) You are given an array of integers. Your task is to find the…
-
Construct and Deconstruct a Pair
Problem Statement (Asked By Jane Street) The function cons(a, b) creates a pair of two elements. Implement two…
-
Implement an XOR Linked List
An XOR-linked list is a memory-efficient version of a doubly linked list. Instead of each node storing separate…
-
Count Decoding Ways for Encoded Messages
Problem Statement (Asked By Facebook) Given the mapping a = 1, b = 2, …, z = 26,…
-
Count Unival Subtrees in a Binary Tree
A unival tree (short for "universal value tree") is a tree in which all nodes have the same…
-
Largest Sum of Non-Adjacent Numbers
Problem Statement (Asked By Airbnb) Given a list of integers, write a function to compute the largest sum…
-
Job Scheduler Implementation
Design a job scheduler that accepts a function f and an integer n. The scheduler should execute the…
-
Autocomplete System Implementation
Build an autocomplete system that, given a query string s and a set of possible query strings returns…
-
Staircase Climbing Ways
There is a staircase with N steps, and you can ascend either 1 step or 2 steps at…
-
Longest Substring with K Distinct Characters
Given an integer k and a string s, write a function to determine the length of the longest…
-
Estimate π Using Monte Carlo Method
The formula for the area of a circle is given by πr². Use the Monte Carlo method to…
-
Select a Random Element from a Stream
You are given a stream of elements that is too large to fit into memory. Write an algorithm…
-
Efficient Order Log Storage
You manage an e-commerce website and need to keep track of the last N order IDs in a…
-
Longest Absolute Path in File System Representation
Find the length of the longest absolute path to a file within the abstracted file system. The length…
-
Minimum Cost to Paint Houses with K Colors
A builder plans to construct N houses in a row, where each house can be painted in K…