随笔分类 -  Hash Table

摘要: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 presen 阅读全文
posted @ 2018-11-15 21:44 Veritas_des_Liberty 阅读(246) 评论(0) 推荐(0)
摘要:Design 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 u 阅读全文
posted @ 2018-11-15 21:03 Veritas_des_Liberty 阅读(201) 评论(0) 推荐(0)
摘要:Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input 阅读全文
posted @ 2018-11-15 15:13 Veritas_des_Liberty 阅读(260) 评论(0) 推荐(0)
摘要:Given 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 arr 阅读全文
posted @ 2018-11-15 14:37 Veritas_des_Liberty 阅读(254) 评论(0) 推荐(0)
摘要:Given 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  阅读全文
posted @ 2018-11-14 22:39 Veritas_des_Liberty 阅读(226) 评论(0) 推荐(0)
摘要:Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runti 阅读全文
posted @ 2018-11-14 21:56 Veritas_des_Liberty 阅读(256) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-11-14 21:23 Veritas_des_Liberty 阅读(261) 评论(0) 推荐(0)
摘要:Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege 阅读全文
posted @ 2018-11-14 19:53 Veritas_des_Liberty 阅读(300) 评论(0) 推荐(0)
摘要:Given 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 lette 阅读全文
posted @ 2018-11-14 16:39 Veritas_des_Liberty 阅读(208) 评论(0) 推荐(0)
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Example 1: Example 2: my code: can't determine the 阅读全文
posted @ 2018-11-13 22:31 Veritas_des_Liberty 阅读(194) 评论(0) 推荐(0)
摘要:Count the number of prime numbers less than a non-negative number, n. Example: Approach #1: C++. Approach #2: Java. Approach #3: Python. 阅读全文
posted @ 2018-11-13 20:22 Veritas_des_Liberty 阅读(299) 评论(0) 推荐(0)
摘要:Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + 阅读全文
posted @ 2018-11-12 19:11 Veritas_des_Liberty 阅读(257) 评论(0) 推荐(0)
摘要:You 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 阅读全文
posted @ 2018-11-12 12:38 Veritas_des_Liberty 阅读(206) 评论(0) 推荐(0)
摘要:Given 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 occurrenc 阅读全文
posted @ 2018-11-12 11:49 Veritas_des_Liberty 阅读(206) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-11-12 10:59 Veritas_des_Liberty 阅读(266) 评论(0) 推荐(0)
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating 阅读全文
posted @ 2018-11-11 22:36 Veritas_des_Liberty 阅读(216) 评论(0) 推荐(0)
摘要:Given a binary tree, return the inorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it iteratively 阅读全文
posted @ 2018-11-11 21:11 Veritas_des_Liberty 阅读(182) 评论(0) 推荐(0)
摘要:Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make pro 阅读全文
posted @ 2018-11-07 19:29 Veritas_des_Liberty 阅读(238) 评论(0) 推荐(0)