![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
文章平均质量分 78
fibo_nacci
C/C coder
展开
-
Leetcode Reverse Integer
地址:http://oj.leetcode.com/problems/reverse-integer/思路:简单吧,直接上代码了。class Solution {public: int reverse(int x) { bool flag = true; if(x < 0) { flag = false;原创 2014-03-09 13:51:32 · 750 阅读 · 0 评论 -
Leetcode_binary-tree-preorder-traversal
地址:http://oj.leetcode.com/problems/binary-tree-preorder-traversal/Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},原创 2014-03-27 23:06:15 · 542 阅读 · 0 评论 -
Leetcode_palindrome-number
http://oj.leetcode.com/problems/palindrome-number/Determine whether an integer is a palindrome. Do this without extra space.注意:负数全部返回false,小于10的自然数都返回true。参考代码:class Solution {public: b原创 2014-03-28 10:56:29 · 505 阅读 · 0 评论 -
Leetcode_subsets
地址:http://oj.leetcode.com/problems/subsets/Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set m原创 2014-03-27 17:40:36 · 499 阅读 · 0 评论 -
Leetcode_remove-element
地址:http://oj.leetcode.com/problems/remove-element/Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It d原创 2014-03-17 20:43:39 · 488 阅读 · 0 评论 -
Leetcode_longest-common-prefix
地址:http://oj.leetcode.com/problems/longest-common-prefix/Write a function to find the longest common prefix string amongst an array of strings.思路:注意strs为空的情况。基本没有算法,考查代码熟练程度。class Solution {p原创 2014-03-17 16:54:49 · 512 阅读 · 0 评论 -
Leetcode_permutations
地址:http://oj.leetcode.com/problems/permutations/Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1原创 2014-04-13 17:11:10 · 512 阅读 · 0 评论 -
Leetcode_permutations-ii
地址:http://oj.leetcode.com/problems/permutations-ii/Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the followi原创 2014-04-13 17:31:46 · 470 阅读 · 0 评论 -
Leetcode_sqrtx
地址:http://oj.leetcode.com/problems/sqrtx/Implement int sqrt(int x).Compute and return the square root of x.思路:主要是处理2147483647这个case吧。同时也要注意上溢出的问题,不然也会TLE。两个参考代码,一个152ms,一个96ms//152msc原创 2014-03-30 15:42:18 · 428 阅读 · 0 评论 -
Leetcode_triangle
地址:http://oj.leetcode.com/problems/triangle/Given 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原创 2014-03-31 22:53:47 · 472 阅读 · 0 评论 -
Leetcode_divide-two-integers(python version)
地址:http://oj.leetcode.com/problems/divide-two-integers/原创 2014-05-01 20:29:41 · 755 阅读 · 1 评论 -
Leetcode_binary-tree-level-order-traversal-ii
地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/Binary Tree Level Order Traversal II Total Accepted: 7574 Total Submissions: 24638My SubmissionsGiven a bi原创 2014-03-20 14:21:22 · 519 阅读 · 0 评论 -
Leetcode_merge-intervals
地址:http://oj.leetcode.com/problems/merge-intervals/Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,1原创 2014-04-01 17:09:49 · 452 阅读 · 0 评论 -
Leetcode_insert-interval
地址:http://oj.leetcode.com/problems/insert-interval/Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals w原创 2014-04-01 19:04:08 · 432 阅读 · 0 评论 -
Leetcode_merge-two-sorted-lists
http://oj.leetcode.com/problems/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 list原创 2014-03-21 23:09:47 · 490 阅读 · 0 评论 -
Leetcode_binary-tree-postorder-traversal
地址:http://oj.leetcode.com/problems/binary-tree-postorder-traversal/Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1原创 2014-04-03 10:51:30 · 421 阅读 · 0 评论 -
Leetcode_rotate-list
地址:http://oj.leetcode.com/problems/rotate-list/Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5原创 2014-03-23 14:24:55 · 524 阅读 · 0 评论 -
Leetcode_unique-binary-search-trees-ii
地址:http://oj.leetcode.com/problems/unique-binary-search-trees-ii/原创 2014-04-18 21:57:58 · 513 阅读 · 0 评论 -
Leetcode_gray-code
地址:http://oj.leetcode.com/problems/gray-code/原创 2014-04-04 16:37:51 · 464 阅读 · 0 评论 -
Leetcode_merge-k-sorted-lists
地址:http://oj.leetcode.com/problems/merge-k-sorted-lists/Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路: 直接全部丢到一个vector里排序。参考代码:/**原创 2014-03-25 18:03:09 · 465 阅读 · 0 评论 -
Leetcode_powx-n(c++ and python version)
地址:http://oj.leetcode.com/problems/powx-n/Implement pow(x, n).s原创 2014-04-25 11:22:18 · 615 阅读 · 0 评论 -
Leetcode_combination-sum
地址: http://oj.leetcode.com/problems/combination-sum/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.Th原创 2014-04-06 13:51:10 · 491 阅读 · 0 评论 -
**Leetcode_distinct-subsequences
地址:http://oj.leetcode.com/problems/distinct-subsequences/Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which原创 2014-04-06 13:01:07 · 556 阅读 · 0 评论 -
Leetcode_best-time-to-buy-and-sell-stock-ii(c++ and python version)
地址: http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the原创 2014-03-31 21:58:20 · 680 阅读 · 0 评论 -
Leetcode_set-matrix-zeroes
地址:http://oj.leetcode.com/problems/set-matrix-zeroes/原创 2014-04-06 17:17:17 · 611 阅读 · 0 评论 -
Leetcode_substring-with-concatenation-of-all-words
地址:http://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/原创 2014-04-07 10:13:14 · 654 阅读 · 0 评论 -
Leetcode_sudoku-solver
地址:http://oj.leetcode.com/problems/sudoku-solver/Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that th原创 2014-04-22 09:49:48 · 572 阅读 · 0 评论 -
Leetcode_palindrome-partitioning
地址:http://oj.leetcode.com/problems/palindrome-partitioning/Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitionin原创 2014-04-22 12:19:10 · 528 阅读 · 0 评论 -
Leetcode_permutation-sequence(c++ and python version)
地址:http://oj.leetcode.com/problems/permutation-sequence/原创 2014-05-08 23:31:32 · 626 阅读 · 0 评论 -
Leetcode_valid-sudoku
地址:http://oj.leetcode.com/problems/valid-sudoku/Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled原创 2014-04-22 09:34:21 · 533 阅读 · 0 评论 -
Leetcode_reverse-linked-list-ii
地址:http://oj.leetcode.com/problems/reverse-linked-list-ii/原创 2014-04-09 14:56:46 · 407 阅读 · 0 评论 -
Leetcode_edit-distance
地址:http://oj.leetcode.com/problems/edit-distance/Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)Y原创 2014-04-09 16:08:15 · 426 阅读 · 0 评论 -
Leetcode_word-ladder(c++ version)
地址:http://oj.leetcode.com/problems/word-ladder/原创 2014-05-15 11:39:56 · 1174 阅读 · 0 评论 -
Leetcode_decode-ways
地址:http://oj.leetcode.com/problems/decode-ways/A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an enco原创 2014-04-09 14:00:21 · 488 阅读 · 0 评论 -
Leetcode_rotate-image
地址:http://oj.leetcode.com/problems/rotate-image/You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?原创 2014-04-25 16:24:24 · 546 阅读 · 0 评论 -
Leetcode_anagrams
地址:http://oj.leetcode.com/problems/anagrams/原创 2014-04-25 15:05:25 · 498 阅读 · 0 评论 -
Leetcode_subsets-ii
地址:http://oj.leetcode.com/problems/subsets-ii/原创 2014-04-10 13:44:53 · 482 阅读 · 0 评论 -
Leetcode_recover-binary-search-tree
地址:http://oj.leetcode.com/problems/recover-binary-search-tree/原创 2014-05-19 10:28:54 · 628 阅读 · 0 评论 -
**Leetcode_lru-cache (c++ version)
地址:http://oj.leetcode.com/problems/lru-cache/原创 2014-05-17 19:25:39 · 725 阅读 · 0 评论 -
*Leetcode_clone-graph(c++ version)
地址:http://oj.leetcode.com/problems/clone-graph/原创 2014-05-17 15:58:33 · 801 阅读 · 0 评论