
Hash Table
文章平均质量分 72
豆腐脑是咸的
这个作者很懒,什么都没留下…
展开
-
Copy List with Random Pointer (Java)
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. 这道题和clone graph那道题不同的地方在于,图可以d原创 2015-01-29 19:51:33 · 451 阅读 · 0 评论 -
Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without原创 2015-02-16 13:46:29 · 501 阅读 · 0 评论 -
Anagrams (Java)
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. 给定一字符串数组,返回其中是由相同字符组成只是顺序不同的字符串子数组,这些字符只出现了一次的字符串不返回。 比如 abb,bab,bba,abc 返回[原创 2015-01-04 21:44:09 · 326 阅读 · 0 评论 -
Single Number (Java)
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ext原创 2015-01-04 16:49:36 · 482 阅读 · 0 评论 -
Max Points on a Line (Java)
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 用斜率算,遍历每一个点,然后以这个点和剩下的所有点连线,斜率相同的放在hash的同一位置。如果有和这个点相同的点统计下来最后算进去。 Source public int maxPoi原创 2015-02-12 14:04:17 · 437 阅读 · 0 评论 -
Fraction to Recurring Decimal (Java)
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses.原创 2015-01-23 10:20:01 · 472 阅读 · 0 评论 -
Repeated DNA Sequences (Java)
All 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 within the DNA. Wri原创 2015-02-18 15:31:09 · 823 阅读 · 0 评论 -
4Sum (Java)
Given 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: Element原创 2015-01-04 15:51:27 · 818 阅读 · 0 评论 -
Longest Substring Without Repeating Characters (Java)
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo原创 2015-01-03 20:23:40 · 291 阅读 · 0 评论 -
Two Sum (Java)
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, whe原创 2015-01-03 22:30:06 · 363 阅读 · 0 评论 -
Sudoku Solver (Java)
Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be only one unique solution. A sudoku原创 2015-02-06 16:24:45 · 337 阅读 · 0 评论 -
Maximal Rectangle (Java)
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. 设一个数组表示从第一行开始遍历的当前列的高度,再用largest rectangle in histogram那道题的方法算最大面积。 Source publ原创 2015-02-05 10:33:20 · 386 阅读 · 0 评论 -
Valid Sudoku (Java)
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partially fille原创 2014-10-28 15:34:10 · 1304 阅读 · 0 评论