Fault-Tolerant Data Transmission
A network packet is received. It might contain exactly one corrupted bit. Verify if the packet string can be a valid palindrome if you are allowed to delete at most one character.
2000+ data structures and algorithms problems, tagged by company and difficulty. Browse the full bank free, then log in to solve, track progress and see detailed solutions.
Difficulty
Category
701 questions
A network packet is received. It might contain exactly one corrupted bit. Verify if the packet string can be a valid palindrome if you are allowed to delete at most one character.
A social network graph returns two unsorted arrays of friend IDs for User A and User B. Return an array of their mutual friends (the intersection of the arrays).
Google Docs resolves two users typing. They type characters and backspaces '#'. Given two strings containing '#' representing backspaces, determine if the final typed results are equal.
A DSP chip outputs an array of signal amplitudes sorted in non-decreasing order (can contain negatives). Return an array of the squares of each amplitude, also sorted in non-decreasing order.
A bank needs to identify complex fraud rings. Given an array of transaction amounts and a target amount, return all unique quadruplets of transactions that sum exactly to the target.
An array holds user IDs. A data purge requires removing all instances of a specific 'banned_id' in-place. Return the number of valid IDs remaining. Order doesn't matter.
A table array has N+1 records with IDs from 1 to N. Due to a replication error, exactly one ID appears multiple times. Find the duplicate ID without modifying the array, using O(1) space.
You have an array of server capacities and an array of task requirements. Assign tasks to servers such that requirement <= capacity. Maximize tasks assigned.
A URL shortening service uses basic compression. Given a compressed string like 'a2b3', decompress it or verify its length compared to the original constraint.
A 3D rendering engine needs to form triangles from an array of edge lengths. Find the number of valid triplets that can form a triangle (sum of two smallest sides > largest side).
Given an integer array nums consisting of n elements, and an integer k. Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value.
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. Return the max sliding window.
Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.
Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray of which the sum is greater than or equal to target.
The frequency of an element is the number of times it occurs in an array. You are given an integer array nums and an integer k. In one operation, you can choose an index and increment the element at that index by 1. Return the maximum possible frequency of an element after performing at most k operations.
Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.
You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times. Return the length of the longest substring containing the same letter you can get.
Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.
There are several cards arranged in a row, and each card has an associated number of points. You can take exactly k cards from either the beginning or the end of the row. Return the maximum score you can obtain.
Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1's in the resulting array.
Given a string s and an integer k, return the number of substrings in s of length k with no repeated characters.
Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.
Given a binary array data, return the minimum number of swaps required to group all 1's present in the array together in any place in the array.
There is a bookstore owner that has a store open for n minutes. You are given an array customers and a binary array grumpy. The owner can use a secret technique to not be grumpy for minutes consecutive minutes. Return the maximum number of customers that can be satisfied.
You are visiting a farm that has a single row of fruit trees arranged from left to right. You have two baskets, and each basket can hold only one type of fruit. Return the maximum number of fruits you can pick.
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Given a string s, return true if it is a palindrome.
Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same.
Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. You must do this in-place.
Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string generated from the original string with some characters deleted without changing relative order.