leetcode实现每周一题
文章平均质量分 82
gordon1986
微软总部,资深软件工程师,有多年前后端,分布式系统开发经验。
展开
-
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 complexity. Could原创 2013-10-25 20:53:14 · 2441 阅读 · 0 评论 -
[leetcode]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 NA P L原创 2015-08-24 09:08:39 · 1221 阅读 · 1 评论 -
Binary Tree Inorder Traversal——二叉树的中序遍历
原题:Given a binary tree, return the inorder traversal of its nodes' values.=>给定一个二叉树,返回所有节点的中序遍历For example:=>例如 Given binary tree {1,#,2,3},=>给定二叉树如下: 1 \ 2 / 3r原创 2014-02-07 09:21:27 · 2579 阅读 · 0 评论 -
Populating Next Right Pointers in Each Node--为每一个节点填充next right指针
原题:Given a binary tree =>给定一个二叉树 struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next原创 2014-01-28 09:25:27 · 1784 阅读 · 0 评论 -
Unique Binary Search Trees——唯一的二叉搜索树
原题:Given n, how many structurally uniqueBST's (binary search trees) that store values 1...n?=>给一个数n,由1~n组成的有多少种二叉搜索树。For example,Given n = 3, there are a total of 5 unique BST's. =>例如:若是原创 2014-01-09 09:39:57 · 2469 阅读 · 0 评论 -
Single Number II -- 找出数组中唯一出现一次的数,其它数都出现了三次
原题:Given an array of integers, every element appears three times except for one. Find that single one.=>给定一个数组,除了一个元素,其它每个元素都出现了三次,找出这个出现一次的元素Note:Your algorithm should have a linear run原创 2014-01-02 09:51:05 · 7190 阅读 · 1 评论 -
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,#,2,3} 1 \ 2原创 2013-11-12 11:27:10 · 1929 阅读 · 1 评论 -
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 \ 2 / 3原创 2013-11-08 09:21:11 · 1990 阅读 · 0 评论 -
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? =>能否不使用额外的空间来解决这个问题?/** * Definition f原创 2013-11-03 08:46:46 · 3515 阅读 · 2 评论 -
Linked List Cycle II--找出单向链表中环的起点
原题:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. =>找到单向链表的环的启动,若没有环,返回nullFollow up:Can you solve it without using extra space? =>能否不使用额外的空原创 2013-11-17 12:00:20 · 3060 阅读 · 3 评论 -
Reverse Integer--整数的反转
原题:Reverse digits of an integer.=>反转一个整数的数字。例子如下:Example1: x = 123, return 321Example2: x = -123, return -321 Have you thought about this?Here are some good questions to ask before codi原创 2013-10-30 09:08:43 · 2342 阅读 · 0 评论 -
Same Tree--比较两个二叉树是否相同
原题:Given 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原创 2013-10-27 11:07:44 · 2760 阅读 · 2 评论 -
Maximum Depth of Binary Tree--二叉树的深度
原题:Given 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.=>所谓的深度就是指原创 2013-10-26 22:06:40 · 1572 阅读 · 0 评论 -
[leetcode]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 elem原创 2015-08-14 12:04:15 · 878 阅读 · 0 评论