Posts with tag 'hash table'

Anagram Substrings

less than 1 minute read

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

Remove Duplicate Numbers

less than 1 minute read

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

1 minute read

Implement a frequency stack with the following methods:

Longest Consecutive Sequence

1 minute read

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

Sum of Four Numbers

1 minute read

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

1 minute read

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

1 minute read

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...

Sort by Frequency and Value

1 minute read

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

2 minute read

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

Bomber Man

less than 1 minute read

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

1 minute read

Implement a data structure with the following methods:

Largest Anagram Group

less than 1 minute read

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

K Unique String

1 minute read

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 ...

Palindromic Anagram

less than 1 minute read

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

Anagram Checks

less than 1 minute read

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

Zero Matrix

1 minute read

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

1 minute read

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

1 minute read

Implement a boolean array which implements the following methods:

Unique People in Contact List

1 minute read

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

1 minute read

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

Tic Tac Toe

2 minute read

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

Swap Characters to Equalize Strings

less than 1 minute read

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

1 minute read

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

less than 1 minute read

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

1 minute read

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

1 minute read

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

1 minute read

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

less than 1 minute read

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

Number of Sublists With Sum of Target

less than 1 minute read

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

Mutual Followers

less than 1 minute read

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

less than 1 minute read

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...

List Partitioning

less than 1 minute read

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.

Leaderboard

less than 1 minute read

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

1 minute read

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

less than 1 minute read

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

less than 1 minute read

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

Hash Table

1 minute read

Implement a hash table with the following methods:

First Missing Positive

1 minute read

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

1 minute read

Implement a data structure with the following methods:

Equivalent Value and Frequency

less than 1 minute read

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

Equivalent Pairs

less than 1 minute read

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

Detect Voter Fraud

less than 1 minute read

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

less than 1 minute read

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

1 minute read

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...

A Unique String

less than 1 minute read

Given a lowercase alphabet string s, determine whether it has all unique characters.

A Number and Its Triple

less than 1 minute read

Given a list of integers nums, return whether there’s two numbers such that one is a triple of another.

Back to top ↑