- 博客(18)
- 收藏
- 关注
原创 Triangle
TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle [ [2], [3,
2018-01-21 00:40:21
235
原创 Path Sum II
Path Sum IIGiven a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.For example: Given the below binary tree and sum = 22, return [ [5,4,11,
2018-01-21 00:39:53
182
原创 Path sum
Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Given the below binary tree and sum = 22
2018-01-21 00:39:14
195
原创 Swap Nodes in Pairs
Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use o
2018-01-21 00:36:38
216
原创 算法概论习题
8.3. STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, and a satisfying assignment in which at most k variables are true, if such an assignm
2018-01-21 00:35:54
420
原创 Pow(x, n)
50. Pow(x, n)Implement pow(x, n).example1 Input: 2.00000, 10 Output: 1024.00000example2 Input: 2.10000, 3 Output: 9.26100这道题要我实现pow(x,n)这个函数,也就是x的n次方的计算。class Solution {pu
2018-01-20 21:10:42
217
原创 Group Anagrams
Group AnagramsGiven an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],renturn: [ [“ate”, “eat”,”tea”], [“nat”,”tan”],
2018-01-20 20:59:37
181
原创 Median of Two Sorted Arrays
Median of Two Sorted ArraysThere are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n))
2018-01-20 19:31:09
149
原创 Multiply Strings
Multiply StringsGiven two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.note:The length of both num1 and num2 is Both num1 and num2 contains o
2018-01-20 19:06:15
223
原创 Integer to Roman
Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.之前写过将罗马数转化为整数,现在回顾一下罗马数的写法 I -> 1 V -> 5 X->10 L-> 50
2018-01-20 18:38:45
143
原创 Add Two Numbers
Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two num
2018-01-20 18:18:35
165
原创 Two Sum
Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not
2018-01-20 18:08:43
224
原创 Valid Parentheses
Valid ParenthesesGiven a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the correct order, “()” and “()[
2018-01-20 17:56:02
169
原创 Longest Common Prefix
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.以第一个String为标准,所有其他的String与第一个String比较,初始化一个String类型prefix来记录结果,当任意一个其他String的第k位与第一个Strin
2018-01-20 17:43:33
141
原创 Palindrome Number
Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.要看x是否是回数,应该初始化一个int类型z,让x的最高位数=z的最低位数,x的第二高位数=z的第二低位数,并以此类推。代码块代码块语法遵循标准markdown代码,例如:class S
2018-01-20 17:28:51
172
原创 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.思路要把两个已经排序的list(L1, L2)合并并且排好序。那么首先比较的就是两个队列的head,然后将val
2017-09-24 16:42:59
176
原创 Roman to Integer
题目描述Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.思路做这道题之前我们首先要懂得罗马数字的写法。 I -> 1 V -> 5 X->10 L-> 50 C->100 D->500 M->10001.相同的数字连写、所表示的数
2017-09-24 15:35:25
178
原创 Count and say[easy on LeetCode]
Count and say[easy on LeetCode]原题地址:https://leetcode.com/problems/count-and-say/description/题目描述The count-and-say sequence is the sequence of integers with the first five terms as following: 1 1
2017-09-11 19:28:23
231
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人