
算法
sunwillz
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode:Isomorphic Strings
原题: 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 occurrences of a character must be replaced with another原创 2016-07-09 20:02:27 · 390 阅读 · 0 评论 -
leetcode(49):Group Anagrams
【题目】 Given an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return: [ [“ate”, “eat”,”tea”], [“nat”,”tan”], [“bat”] ]【分析】题意为将字符串数组中原创 2016-08-22 16:03:37 · 537 阅读 · 0 评论 -
leetcode(368):Largest Divisible Subset
原题: Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple solutions, r原创 2016-08-10 21:49:45 · 525 阅读 · 0 评论 -
leetcode(375):Guess Number Higher or Lower II
原题: We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I’ll tell you whether the number I picked is原创 2016-08-11 17:43:52 · 792 阅读 · 0 评论 -
leetcode(187):Repeated DNA Sequences
原题: 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.Wr原创 2016-08-11 20:11:13 · 289 阅读 · 0 评论 -
leetcode(318):Maximum Product of Word Lengths
原题: Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case原创 2016-08-11 20:58:23 · 299 阅读 · 0 评论 -
leetcode(78):Subsets
原题: Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,3], a solution is: [ [3], [1], [2原创 2016-08-11 21:37:35 · 296 阅读 · 0 评论 -
leetcode(274):H-Index
原题: Given 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: “A原创 2016-08-12 13:07:07 · 312 阅读 · 0 评论 -
leetcode(90):Subsets II
原题: Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,2], a solutio原创 2016-08-12 15:57:52 · 310 阅读 · 0 评论 -
leetcode(150):Evaluate Reverse Polish Notation
原题: Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: [“2”, “1”, “+”, “3”,原创 2016-08-13 13:43:27 · 301 阅读 · 0 评论 -
leetcode[200]:Number of Islands
【原题】 Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may a原创 2016-09-16 19:45:49 · 490 阅读 · 1 评论 -
leetcode(282): Expression Add Operators
Given a string that contains only digits 0-9 and a target value,return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value. Examples原创 2016-08-13 15:04:05 · 914 阅读 · 0 评论 -
leetcode(51):N-Queens
【原题】 The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle.Ea原创 2016-12-21 12:01:01 · 317 阅读 · 0 评论 -
leetcode[52]:N-Queens II
【原题】 Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions.【分析】 本题为N皇后问题,要求解的个数 思路是回溯法,一行一行地遍历,每个位置试一下,看能否构成解。 由题目要求,同一行、同一列原创 2016-12-21 14:33:38 · 402 阅读 · 0 评论 -
leetcode(45):Jump Game II
原题: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to原创 2016-08-10 11:32:52 · 259 阅读 · 0 评论 -
leetcode(316):Remove Duplicate Letters
原题: Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical ord原创 2016-08-10 10:36:30 · 432 阅读 · 0 评论 -
leetcode[208]:Implement Trie (Prefix Tree)
【题目】 Implement a trie with insert, search, and startsWith methods.Note: You may assume that all inputs are consist of lowercase letters a-z. 【解析】 题目要求实现Prefix Tree(前缀树)的insert、search和startWith方法,所以原创 2016-08-20 15:06:29 · 511 阅读 · 0 评论 -
leetcode:Top K Frequent Elements
原题: Given a non-empty array of integers, return the k most frequent elements. For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note:You may assume k is always valid, 1 ≤ k ≤ number of unique原创 2016-07-10 15:15:45 · 434 阅读 · 0 评论 -
leetcode:Counting Bits
原题: Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 y原创 2016-07-11 19:48:33 · 388 阅读 · 0 评论 -
leetcode 125:Valid Palindrome
原题: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car” i原创 2016-07-12 09:36:47 · 395 阅读 · 0 评论 -
leetcode:Binary Tree Level Order Traversal
原题: Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7] 3原创 2016-07-13 23:19:24 · 355 阅读 · 0 评论 -
leetcode:First Missing Positive
原题:Given an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space原创 2016-07-14 22:06:54 · 253 阅读 · 0 评论 -
leetcode 204:Count Primes
原题:Count the number of prime numbers less than a non-negative number, n.求小于正整数n的质数的个数通常我们的做法是从最小的质数2开始遍历直到n,判断其中每一个数是否为质数,当n很大的时候,肯定超时。有更高效的解法如下:质数只能被1和他自己整除,也就是说他不包含基本因子2,3,5,7等我们可以排除上述这些数来大大提高遍历效率2是最原创 2016-07-15 16:10:33 · 481 阅读 · 0 评论 -
leetcode: Missing Number
原题: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 usin原创 2016-07-09 13:31:42 · 435 阅读 · 0 评论 -
leetcode :Reverse Vowels of a String
原题:Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".原创 2016-07-09 14:04:01 · 429 阅读 · 0 评论 -
leetcode: Word Pattern
原题: 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 letter in pattern and a non-empty word in str.Exampl原创 2016-07-09 19:03:26 · 438 阅读 · 0 评论 -
leetcode(17):Letter Combinations of a Phone Number
原题: Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit strin原创 2016-08-15 17:28:31 · 322 阅读 · 0 评论 -
leetcode:Combination Sum(I,II)
原题: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number原创 2016-08-15 19:56:19 · 276 阅读 · 0 评论 -
leetcode():Permutations
Permutations : Given a collection of distinct numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],原创 2016-08-16 17:40:44 · 470 阅读 · 0 评论 -
leetcode(155):Min Stack
**【题目】 Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top()原创 2016-08-29 09:58:08 · 618 阅读 · 0 评论 -
leetcode(410):Split Array Largest Sum
【原题】 Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these原创 2016-12-21 23:31:56 · 445 阅读 · 0 评论