- 博客(22)
- 资源 (2)
- 收藏
- 关注
原创 leetcode166. Fraction to Recurring Decimal
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.For exam
2016-01-26 20:23:00 313
原创 leetcode187. 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.Write a
2016-01-26 15:12:50 303
原创 leetcode136. Single 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 using extra me
2016-01-26 14:22:10 237
转载 leetcode49. 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”] ] Note: For the re
2016-01-25 20:22:17 294
原创 leetcode3. Longest Substring Without Repeating Characters
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. For “
2016-01-25 17:37:09 241
原创 leetcode18. 4Sum
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: Elements in a quad
2016-01-25 11:46:01 266
原创 leetcode274. 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 scien
2016-01-25 09:59:39 291
原创 leetcode204. Count Primes
Description:Count the number of prime numbers less than a non-negative number, n. javapublic class Solution { public int countPrimes(int n) { boolean[] a= new boolean[n]; for (in
2016-01-23 18:33:14 304
原创 leetcode219. Contains Duplicate II
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 difference between i and j is at most k. 思路 一开
2016-01-23 16:59:24 287
原创 leetcode202. Happy Number
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 integer, replace the number by the sum of the squares of i
2016-01-23 16:36:07 295
原创 leetcode299. Bulls and Cows
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 your friend makes a guess, you provide a hint that
2016-01-23 16:08:19 318
原创 Leetcode290. Word Pattern & 205. Isomorphic Strings
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.Examples:
2016-01-23 13:46:54 357
原创 leetcode1 Two Sum
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, where in
2016-01-23 12:31:11 250
原创 coursera公开课——recommender system作业(第三周)
懒虫锅~~~!!!! 原始数据: 以及用户目前对doc的数据 #coding:utf-8import csvimport operatorimport mathcsvfile=file("data1.csv",'rU')reader=csv.reader(csvfile,dialect='excel')doc={}item=[]for line in reader:
2016-01-22 17:23:42 1064 1
原创 leetcode21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Subscribe to see which companies asked this question 思路: 因
2016-01-21 17:56:24 210
原创 leetcode19. Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list be
2016-01-21 17:54:49 219
原创 leetcode2 Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linke
2016-01-21 17:52:30 226
原创 leetcode150 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-01-19 19:04:06 225
原创 leetcode32 Longest Valid Parentheses
Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses substring is “()”, which has
2016-01-19 19:02:55 254
原创 leetcode 20 Valid Parentheses
Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the correct order, “()” and “()[]{}” are all valid but “
2016-01-19 19:01:48 214
原创 leetcode84: Largest Rectangle in Histogram
84. Largest Rectangle in Histogram height的内容是 [5,6,7,8,3],特点是除了最后一个,前面全部保持递增,且最后一个立柱的高度小于前面所有立柱高度。对于这种特点的柱状图,如果使用上面所说的“挨个使用每一个柱状图的高度作为矩形的高度,求面积”的方法,还需要用嵌套循环吗?我们知道除了最后一个,从第一个到倒数第二个立柱的高度都在升高,那么如果挨个使用每一个
2016-01-19 19:00:29 408
原创 n-armed bandit _ ucb1 algorithm
前言:家里发生了一些事情,所以又耽搁了一段时间,这周交的report都有点潦草,好在ucb1本身就不是一个很复杂的算法。 This week, I have studied one of the algorithms in the UCB falmily, which is called the UCB1 algorithm.The UCB1 algorithm pays attention to
2016-01-09 10:04:46 3432 1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人