# Posts with tag 'hash table'

## Anagram Substrings

Given two strings s0 and s1, return the number of substrings where s1 contains any anagram of s0.

## Remove Duplicate Numbers

Given a list of integers nums, remove numbers that appear multiple times in the list, while maintaining order of the appearance in the original list.

## Frequency Stack

Implement a frequency stack with the following methods:

## Longest Consecutive Sequence

Given an unsorted array of integers nums, find the length of the longest sequence of consecutive elements.

## Longest Substring with 2 Distinct Characters

Given a string s, find the length of the longest substring that contains at most 2 distinct characters.

## Sum of Four Numbers

Given a list of integers nums and an integer k, return whether there are four distinct elements in the list that add up to k.

## Sum Pairs to Target

You are given a list of integers nums and an integer target. In one operation we can remove any two numbers in nums if the pair sums to target. Return the ma...

## Characters in Each Bracket Depth

You are a given a string s containing "X", "(", and ")". The string has balanced brackets and in between there are some "X"s along with possibly nested brack...

## Earliest Uniques in a Stream

Implement a data structure with the following methods:

## Sort by Frequency and Value

Given a list of integers nums, order nums by frequency, with most frequent values coming first. If there’s a tie in frequency, higher valued numbers should c...

## Condo Developers

You are given a two-dimensional integer matrix, where matrix[r][c] represents the height of a condominium in a city.

## Bomber Man

You are given a two-dimensional integer matrix of 1s and 0s, where a 1 represents a bomb and 0 represents an empty cell. When a bomb explodes, all the spaces...

## Underground Tunnel

Implement a data structure with the following methods:

## Largest Anagram Group

Given a list of strings words, group all anagrams together and return the size of the largest grouping.

## K Unique String

Given a string s of lowercase alphabet characters, and an integer k, return the minimum number of changes needed in the string (one change involves changing ...

## Count of Sublists with Same First and Last Values

Given a list of integers nums, return the number of sublists where the first element and the last element have the same value.

## Palindromic Anagram

Given a string s, determine whether any anagram of s is a palindrome.

## Anagram Checks

Given two strings s0 and s1, return whether they are anagrams of each other.

## Zero Matrix

Given a two-dimensional matrix of integers, for each zero in the original matrix, replace all values in its row and column with zero, and return the resultin...

## Word Formation

Given a list of strings words and a string letters, return the length of longest string in words that can be made from letters in letters. If no word can be ...

## Virtual Boolean Array

Implement a boolean array which implements the following methods:

## Unique People in Contact List

You are given a two-dimensional list of strings contacts. Each element contacts[i] represents the list of emails for contact i. Contact i is considered a dup...

## Unique Occurrences

Given a list of integers nums, return whether the number of occurrences of every value in the array is unique.

## Tic Tac Toe

Implement the tic-tac-toe game with the following methods:

## Swap Characters to Equalize Strings

You are given two lowercase alphabet strings s and t, both of them the same length. You can pick one character in s and another in t and swap them. Given you...

## Sum of Two Numbers

Given a list of numbers nums and a number k, return whether any two elements from the list add up to k. You may not use the same element twice.

## Sum of Three Numbers

Given a list of integers nums and an integer k, determine if there are three distinct elements in the list that add up to k.

## String Isomorphism

Given lowercase alphabet strings s, and t return whether you can create a 1-to-1 mapping for each letter in s to another letter (could be the same letter) su...

## Shortest Sublist With Max Frequency

You are given a list of integers nums. Let k be the frequency of a most frequent number in nums. Return the length of a shortest sublist such that the freque...

## Selling Products

You are given a list of integers items and an integer n. A salesperson has items in a bag with random IDs. The salesperson can remove as many as n items from...

## Remove Last Duplicate Entries

Given a list of integers nums, find all duplicate numbers and delete their last occurrences.

## Number of Sublists With Sum of Target

Given a list of integers nums and an integer target, return the number of sublists whose sum is equal to target.

## Mutual Followers

You are given a two-dimensional list of integers relations. Each element relations[i] contains [a, b] meaning that person a is following person b on Twitter.

## Minimum String

You are given two strings s and t of equal length only consisting of lowercase letters. Assuming that you can first rearrange s into any order, return the mi...

## Minimize Number of Unique Integers After Removals

You are given a list of integers nums and an integer n. Given you must remove exactly n numbers, return the least number of unique integers after the removal...

## List Partitioning

Given a list of strings strs, containing the strings "red", "green" and "blue", partition the list so that the red come before green, which come before blue.

You are given a list of integers nums, representing the number of chess matches each person has won. Return a relative ranking (0-indexed) of each person. If...

## Latin Square

Given an n by n matrix of letters matrix, return whether there are exactly n different letters that appear in the matrix and each letter appears exactly once...

## K and -K

Given a list of integers nums, return the largest integer k where k and -k both exist in nums (they can be the same integer). If there’s no such integer, ret...

## High Frequency

Given a list of integers nums, find the most frequently occurring element and return the number of occurrences of that element.

## Hash Table

Implement a hash table with the following methods:

## First Missing Positive

Given a list of integers nums, find the first missing positive integer. In other words, find the lowest positive integer that does not exist in the list. The...

## File System

Implement a data structure with the following methods:

## Equivalent Value and Frequency

Given a list of integers nums, return whether there’s an integer whose frequency in the list is same as its value.

## Equivalent Pairs

You are given a list of integers nums. Return the number of pairs i < j such that nums[i] = nums[j].

## Detect Voter Fraud

Given a two dimensional list of integers votes, where each list has two elements [candidate_id, voter_id], report whether any voter has voted more than once.

## Common Words

Given two strings s0 and s1, each representing a sentence, return the number of unique words that are shared between the two sentences.

## City Blocks

You are given a two-dimensional matrix of unique strings representing city blocks, and a list of strings blocks to visit. Given that you are sitting at block...