
leetcode
文章平均质量分 77
陈止风
个人主页:http://www.yingzinanfei.com
github: https://github.com/cpys
展开
-
leetcode100题 题解 翻译 C语言版 Python版
100. Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same原创 2016-02-07 21:11:42 · 4433 阅读 · 0 评论 -
leetcode110题 题解 翻译 C语言版 Python版
110. Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two sub原创 2016-04-14 21:01:46 · 1478 阅读 · 0 评论 -
leetcode27题 题解 翻译 C语言版 Python版
27. Remove ElementGiven an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place w原创 2016-04-15 09:43:08 · 2104 阅读 · 0 评论 -
leetcode26题 题解 翻译 C语言版 Python版
26. Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for原创 2016-04-15 10:28:06 · 1441 阅读 · 0 评论 -
leetcode101题 题解 翻译 C语言版 Python版
101. Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \原创 2016-04-14 21:34:41 · 1752 阅读 · 0 评论 -
leetcode66题 题解 翻译 C语言版 Python版
66. Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.66原创 2016-04-15 10:45:59 · 1623 阅读 · 0 评论 -
leetcode118题 题解 翻译 C语言版 Python版
118. Pascal's TriangleGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]原创 2016-04-17 14:26:19 · 1508 阅读 · 0 评论 -
leetcode111题 题解 翻译 C语言版 Python版
111. Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node原创 2016-04-19 15:17:00 · 857 阅读 · 0 评论 -
leetcode112题 题解 翻译 C语言版 Python版
112. 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.For example:Given the below bin原创 2016-04-19 15:05:29 · 1004 阅读 · 0 评论 -
leetcode36题 题解 翻译 C语言版 Python版
36. Valid SudokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.原创 2016-04-19 19:42:11 · 911 阅读 · 0 评论 -
leetcode88题 题解 翻译 C语言版 Python版
88. Merge Sorted ArrayGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or e原创 2016-04-19 19:48:50 · 1983 阅读 · 0 评论 -
leetcode223题 题解 翻译 C语言版 Python版
223. Rectangle AreaFind the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.原创 2016-04-19 21:11:30 · 941 阅读 · 0 评论 -
leetcode344题 题解 翻译 C语言版 Python版
344. Reverse StringWrite a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".344.逆转字符串写一个函数,功能是输入一个字符串然后输入其逆序后的结果例原创 2016-07-15 15:50:59 · 1091 阅读 · 0 评论 -
leetcode1题 题解 翻译 C语言版 Python版
1. 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.Exampl原创 2016-11-08 17:30:40 · 1963 阅读 · 0 评论 -
leetcode3题 题解 翻译 C语言版 Python版
3. Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc",原创 2016-11-08 23:24:30 · 981 阅读 · 0 评论 -
leetcode4题 题解 翻译 C语言版 Python版
4. 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(l原创 2016-11-09 11:23:40 · 1741 阅读 · 1 评论 -
leetcode 题解 翻译 C语言 Python 合集 (不断更新)
leetcode100题 题解 翻译 C语言版 Python版leetcode104题 题解 翻译 C语言版 Python版leetcode171题 题解 翻译 C语言版 Python版leetcode226题 题解 翻译 C语言版 Python版leetcode237题 题解 翻译 C语言版 Python版leetcode242题 题解 翻译 C语言版 Pyt原创 2016-02-08 19:05:45 · 2280 阅读 · 0 评论 -
leetcode24题 题解 翻译 C语言版 Python版
24. 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 shou原创 2016-04-14 20:46:54 · 1074 阅读 · 0 评论 -
leetcode21题 题解 翻译 C语言版 Python版
21. Merge Two Sorted ListsMerge 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.21.合并两个有序链表合并两个有序链表并将其作为一原创 2016-04-14 19:49:44 · 2046 阅读 · 0 评论 -
leetcode231题 题解 翻译 C语言版 Python版
231. Power of TwoGiven an integer, write a function to determine if it is a power of two.231.2的幂给定一个整数,写一个函数来判断他是不是2的幂。思路:将其一直除2即可,如果出现余数不为0的情况,就不是2的幂,如果一直除到头了余数一直是0,则是2的幂。程序中可使用与1与运算来原创 2016-02-16 14:33:54 · 670 阅读 · 0 评论 -
leetcode242题 题解 翻译 C语言版 Python版
242. Valid AnagramGiven two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return fals原创 2016-02-07 21:51:30 · 980 阅读 · 0 评论 -
leetcode171题 题解 翻译 C语言版 Python版
171. Excel Sheet Column NumberRelated to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A ->原创 2016-02-07 22:50:48 · 1162 阅读 · 0 评论 -
leetcode292题 题解 翻译 C语言版 Python版
292. Nim GameYou are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the las原创 2016-02-03 16:51:34 · 805 阅读 · 0 评论 -
leetcode258题 题解 翻译 C语言版 Python版
258. Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1原创 2016-02-03 17:27:59 · 1337 阅读 · 0 评论 -
leetcode104题 题解 翻译 C语言版 Python版
104. Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node原创 2016-02-03 21:35:58 · 1598 阅读 · 0 评论 -
leetcode237题 题解 翻译 C语言版 Python版
237. Delete Node in a Linked ListWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and原创 2016-02-04 21:25:59 · 1055 阅读 · 0 评论 -
leetcode226题 题解 翻译 C语言版 Python版
226. Invert Binary TreeInvert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this原创 2016-02-04 21:41:16 · 1251 阅读 · 0 评论 -
leetcode283题 题解 翻译 C语言版 Python版
283. Move ZeroesGiven an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3,原创 2016-02-05 12:27:24 · 724 阅读 · 0 评论 -
leetcode235题 题解 翻译 C语言版 Python版
235. Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on原创 2016-02-08 19:55:06 · 1121 阅读 · 0 评论 -
leetcode206题 题解 翻译 C语言版 Python版
206. Reverse Linked ListReverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?206.倒置一个链原创 2016-02-09 19:26:22 · 1406 阅读 · 0 评论 -
leetcode328题 题解 翻译 C语言版 Python版
328. Odd Even Linked ListGiven a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes原创 2016-02-10 12:21:58 · 818 阅读 · 0 评论 -
leetcode191题 题解 翻译 C语言版 Python版
191. Number of 1 BitsWrite a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has b原创 2016-02-11 22:28:38 · 678 阅读 · 0 评论 -
leetcode70题 题解 翻译 C语言版 Python版
70. Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?70.原创 2016-02-13 17:21:51 · 1665 阅读 · 0 评论 -
leetcode83题 题解 翻译 C语言版 Python版
83. Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3原创 2016-02-14 15:02:04 · 1499 阅读 · 0 评论 -
leetcode263题 题解 翻译 C语言版 Python版
263. Ugly NumberWrite a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example,6, 8 are ugly whil原创 2016-02-15 12:30:14 · 526 阅读 · 0 评论 -
leetcode326题 题解 翻译 C语言版 Python版
326. Power of ThreeGiven an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?326.3的幂给定一个整数,写一个函数来判断它是不是原创 2016-02-15 20:01:14 · 700 阅读 · 0 评论 -
leetcode2题 题解 翻译 C语言版 Python版
2. Add Two NumbersYou 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 numbe原创 2016-11-08 22:51:02 · 3598 阅读 · 4 评论