
LeetCode
文章平均质量分 59
ruzhuxiaogu
人如果没有梦想,和咸鱼有什么区别。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Flatten Binary Tree to Linked List
* * For example, * Given * * 1 * / \ * 2 5 * / \ \ * 3 4 6 *原创 2015-08-09 20:42:38 · 518 阅读 · 0 评论 -
Majority Element:主元素
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element原创 2015-08-09 21:04:18 · 539 阅读 · 0 评论 -
ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I原创 2015-08-10 09:59:14 · 875 阅读 · 1 评论 -
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 link原创 2015-08-09 22:55:45 · 591 阅读 · 0 评论 -
LeetCode:Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 解题思路:类似于后序遍历的思想,递归的思想,先完成左子树的交换,再完成右子树的交换,再将根节点的左右子树交换。 未优化代码如下:原创 2015-08-12 23:20:07 · 597 阅读 · 1 评论 -
LeetCode:Binary Tree Paths 简洁算法
Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: ["1->2->5", "1->3"]原创 2015-08-31 19:36:32 · 533 阅读 · 1 评论 -
LeetCode:Balanced Binary Tree
Given 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 subtrees of every node never diffe原创 2015-09-05 16:40:51 · 455 阅读 · 1 评论 -
LeetCode: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原创 2015-09-10 22:12:24 · 428 阅读 · 0 评论 -
Odd Even Linked List
Given 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. You should try to do it in原创 2016-02-04 22:45:26 · 389 阅读 · 0 评论