
LeetCode
文章平均质量分 79
lilongmark
Work hard. Have fun. Make history.
展开
-
LeetCode 69 — Sqrt(x)(C++ Java Python)
题目:http://oj.leetcode.com/problems/sqrtx/Implement int sqrt(int x).Compute and return the square root of x.题目翻译:实现int sqrt(int x)。计算并返回x的平方根。分析: 二分查找。注意结果不是整数时应返回整数部分。C++实现:原创 2014-02-26 21:39:03 · 3991 阅读 · 0 评论 -
LeetCode 8 — String to Integer (atoi)(C++ Java Python)
题目:http://oj.leetcode.com/problems/string-to-integer-atoi/Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please原创 2014-02-22 20:52:16 · 4760 阅读 · 0 评论 -
LeetCode 7 — Reverse Integer(C++ Java Python)
题目:http://oj.leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some原创 2014-02-22 10:15:19 · 6055 阅读 · 1 评论 -
LeetCode 136 — Single Number(C++ Java Python)
题目:http://oj.leetcode.com/problems/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 com原创 2014-02-20 15:43:27 · 4776 阅读 · 0 评论 -
LeetCode 2 — Add Two Numbers(C++ Java Python)
题目:http://oj.leetcode.com/problems/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 sing原创 2014-02-20 14:34:05 · 8235 阅读 · 0 评论 -
LeetCode 3 — Longest Substring Without Repeating Characters (C++ Java Python)
题目:http://oj.leetcode.com/problems/longest-substring-without-repeating-characters/]Given a string, find the length of the longest substring without repeating characters. For example, the longest sub原创 2014-02-18 22:22:49 · 5724 阅读 · 3 评论 -
LeetCode 4 — Median of Two Sorted Arrays (C++ Java Python)
题目:http://oj.leetcode.com/problems/median-of-two-sorted-arrays/There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time comple原创 2014-02-17 22:06:53 · 6403 阅读 · 2 评论 -
LeetCode 1 — Two Sum(C++ Java Python)
题目: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,原创 2014-02-16 22:23:19 · 19168 阅读 · 9 评论 -
LeetCode 142 — Linked List Cycle II(C++ Java Python)
题目:http://oj.leetcode.com/problems/linked-list-cycle-ii/Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using ex原创 2014-02-27 21:43:40 · 2986 阅读 · 0 评论 -
LeetCode 21 — Merge Two Sorted Lists(C++ Java Python)
题目: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 lists原创 2014-02-27 22:06:33 · 4044 阅读 · 0 评论 -
LeetCode 150 — Evaluate Reverse Polish Notation(C++ Java Python)
题目:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be原创 2014-03-01 15:34:39 · 3471 阅读 · 2 评论 -
LeetCode 26 — Remove Duplicates from Sorted Array(C++ Java Python)
题目:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.原创 2014-02-23 15:12:20 · 5385 阅读 · 0 评论 -
LeetCode 27 — Remove Element(C++ Java Python)
题目: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-02-23 15:54:54 · 5403 阅读 · 0 评论 -
LeetCode 19 — Remove Nth Node From End of List(C++ Java Python)
题目:http://oj.leetcode.com/problems/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原创 2014-02-23 12:00:32 · 3049 阅读 · 0 评论 -
LeetCode 64 — Minimum Path Sum(C++ Java Python)
题目:http://oj.leetcode.com/problems/minimum-path-sum/Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its原创 2014-02-26 22:09:52 · 3450 阅读 · 0 评论 -
LeetCode 147 — Insertion Sort List(C++ Java Python)
题目:http://oj.leetcode.com/problems/insertion-sort-list/Sort a linked list using insertion sort.题目翻译:使用插入排序对链表进行排序。分析: 注意细节。C++实现:/** * Definition for singly-linked list. * str原创 2014-02-27 21:03:49 · 5561 阅读 · 2 评论 -
LeetCode 141 — Linked List Cycle(C++ Java Python)
题目:http://oj.leetcode.com/problems/linked-list-cycle/Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?题目翻译:给定一个链表,确定它是否有环。进阶:你可原创 2014-02-27 21:26:32 · 3431 阅读 · 0 评论 -
LeetCode 67 — Add Binary(C++ Java Python)
题目:http://oj.leetcode.com/problems/add-binary/Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题目翻译:给定两个二进制字符串,返回它们的和(也是一个二进制字符串)原创 2014-02-26 21:18:58 · 2950 阅读 · 0 评论 -
LeetCode 63 — Unique Paths II(C++ Java Python)
题目:http://oj.leetcode.com/problems/unique-paths-ii/Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty原创 2014-02-25 22:19:29 · 3443 阅读 · 0 评论 -
LeetCode 61 — Rotate List(C++ Java Python)
题目: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-02-24 22:11:31 · 3327 阅读 · 0 评论 -
LeetCode 53 — Maximum Subarray(C++ Java Python)
题目:http://oj.leetcode.com/problems/maximum-subarray/Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1原创 2014-02-24 21:57:51 · 3856 阅读 · 0 评论 -
LeetCode 58 — Length of Last Word(C++ Java Python)
题目:http://oj.leetcode.com/problems/length-of-last-word/Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.原创 2014-02-24 21:09:18 · 3649 阅读 · 0 评论 -
LeetCode 62 — Unique Paths(C++ Java Python)
题目:http://oj.leetcode.com/problems/unique-paths/A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right a原创 2014-02-23 22:00:50 · 3406 阅读 · 0 评论 -
LeetCode 35 — Search Insert Position(C++ Java Python)
题目:http://oj.leetcode.com/problems/search-insert-position/Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were原创 2014-02-23 21:06:55 · 3265 阅读 · 0 评论 -
LeetCode 149 — Max Points on a Line(C++ Java Python)
题目:http://oj.leetcode.com/problems/max-points-on-a-line/Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.题目翻译:给定二维平面上的n个点,找出位于同一直线上的点的最大数目。分析:原创 2014-03-02 10:50:24 · 4759 阅读 · 2 评论 -
LeetCode 148 — Sort List(C++ Java Python)
题目:http://oj.leetcode.com/problems/sort-list/Sort a linked list in O(n log n) time using constant space complexity.题目翻译:在O(nlogn)时间内,使用常数空间对链表进行排序。分析: 使用归并排序,复用Merge Two Sorted Lists代原创 2014-03-02 12:16:54 · 4558 阅读 · 1 评论 -
LeetCode 12 — Integer to Roman(C++ Java Python)
题目:http://oj.leetcode.com/problems/integer-to-roman/Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.题目翻译:给定一个整数,将其转换成罗马数字。输入在1到3原创 2014-04-03 14:55:44 · 2512 阅读 · 0 评论 -
LeetCode 112 — Path Sum(C++ Java Python)
题目:题目翻译:分析:C++实现:Java实现:Python实现:感谢阅读,欢迎评论!原创 2014-04-03 16:01:19 · 3533 阅读 · 0 评论 -
LeetCode 14 — Longest Common Prefix(C++ Java Python)
题目:http://oj.leetcode.com/problems/longest-common-prefix/Write a function to find the longest common prefix string amongst an array of strings.题目翻译:编写一个函数找出字符串数组的最长公共前缀子串。分析: 如果字符串数原创 2014-04-03 18:42:35 · 3695 阅读 · 0 评论 -
LeetCode 34 — Search for a Range(C++ Java Python)
题目:题目翻译:分析:C++实现:Java实现:Python实现:感谢阅读,欢迎评论!原创 2014-04-03 20:53:45 · 4329 阅读 · 0 评论 -
LeetCode 28 — Implement strStr()(C++ Java Python)
题目:题目翻译:分析:C++实现:Java实现:Python实现:感谢阅读,欢迎评论!原创 2014-04-14 09:26:12 · 3884 阅读 · 0 评论 -
LeetCode 22 — Generate Parentheses(C++ Java Python)
题目:http://oj.leetcode.com/problems/generate-parentheses/Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solut原创 2014-04-17 11:11:41 · 4561 阅读 · 0 评论 -
LeetCode 97 — Interleaving String (C++ Python)
题目:https://oj.leetcode.com/problems/interleaving-string/Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",Whe原创 2014-07-31 22:44:18 · 1702 阅读 · 0 评论 -
LeetCode 160 — Intersection of Two Linked Lists(C++ Python)
题目:https://oj.leetcode.com/problems/intersection-of-two-linked-lists/Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two原创 2014-12-02 20:59:16 · 2998 阅读 · 0 评论 -
LeetCode 72 — Edit Distance(C++ Python)
题目:https://oj.leetcode.com/problems/edit-distance/原创 2014-07-31 22:24:13 · 1795 阅读 · 0 评论 -
LeetCode题解汇总(C++ Java Python,含题目翻译)
LeetCode题目(含AC Rates):http://oj.leetcode.com/problems/我的github:https://github.com/lilong-dream/1 Two Sumhttp://blog.youkuaiyun.com/lilong_dream/article/details/192983572 Median of Two Sorted Arrays原创 2014-02-23 17:49:09 · 47540 阅读 · 1 评论 -
LeetCode 33 — Search in Rotated Sorted Array(C++ Java Python)
题目:http://oj.leetcode.com/problems/search-in-rotated-sorted-array/Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).原创 2014-04-03 14:20:40 · 2426 阅读 · 0 评论 -
LeetCode 98 — Validate Binary Search Tree(C++ Java Python)
题目:http://oj.leetcode.com/problems/validate-binary-search-tree/Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtre原创 2014-04-02 09:51:35 · 3071 阅读 · 1 评论 -
LeetCode 66 — Plus One(C++ Java Python)
题目:http://oj.leetcode.com/problems/plus-one/Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant d原创 2014-04-02 08:53:48 · 4466 阅读 · 3 评论 -
LeetCode 144 — Binary Tree Preorder Traversal(C++ Java Python)
题目: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}, 1 \原创 2014-03-02 22:13:14 · 3658 阅读 · 3 评论