標籤:: HashTable

0

Insert Delete GetRandom O(1)

Insert Delete GetRandom O(1)Design a data structure that supports all following operations in average O(1) time. insert(val): Inserts an item val to the set if not already present. remove(val): Remo

0

Design Twitter

Design TwitterDesign a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user’s news feed. Your design should

0

Top K Frequent Elements

Top K Frequent ElementsGiven a non-empty array of integers, return the k most frequent elements. For example:1Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assume k is always valid, 1 ≤

0

Bulls and Cows

Bulls and CowsYou are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you pro

0

H-Index

H-IndexGiven an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index. According to the definition of h-index on Wikipedia

0

Repeated DNA Sequences

Repeated DNA SequencesAll DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identify repeated sequences

0

Binary Tree Inorder Traversal

Binary Tree Inorder TraversalGiven a binary tree, return the inorder traversal of its nodes’ values. For example:Given binary tree [1,null,2,3], 123451 \ 2 /3 return [1,3,2]. Note: Recursive solutio

0

Group Anagrams

Group AnagramsGiven an array of strings, group anagrams together. For example:Given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],Return: 12345[ ["ate", "eat","tea"], [&

0

4Sum

4SumGiven an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The solution

0

Longest Substring Without Repeating Characters

Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For Examples:12345Given "abcabcbb", the answer is "

0

Keyboard Row

Keyboard RowGiven a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below. For Example:12Input: ["Hello",

0

Island Perimeter

Island PerimeterYou are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The gr

0

Number of Boomerangs

Number of BoomerangsGiven n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k

0

Find All Anagrams in a String

Find All Anagrams in a StringGiven a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of both stri

0

Longest Palindrome

Longest PalindromeGiven a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This is case sensitive, for example

0

Intersection of Two Arrays

Intersection of Two ArraysGiven two arrays, write a function to compute their intersection. ###For Example: 1Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the result

0

Intersection of Two Arrays II

Intersection of Two Arrays IIGiven two arrays, write a function to compute their intersection. For Example:1Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the resul

0

Word Pattern

Word PatternGiven a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in

0

Palindrome Linked List

Palindrome Linked ListGiven two strings s and t, write a function to determine if t is an anagram of s. For example:12s = "anagram", t = "nagaram", return true.s = "rat"

0

Contains Duplicate II

Contains Duplicate IIGiven an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between

0

Contains Duplicate

Contains DuplicateGiven an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false

0

Isomorphic Strings

Isomorphic StringsGiven two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be repla