leetcode 543. Diameter of Binary Tree
摘要:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe
阅读全文
posted @
2018-03-01 09:28
Beserious
阅读(93)
推荐(0) 编辑
leetcode 551. Student Attendance Record I
摘要:You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : L
阅读全文
posted @
2018-03-01 09:14
Beserious
阅读(116)
推荐(0) 编辑
leetcode 563. Binary Tree Tilt
摘要:Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subt
阅读全文
posted @
2018-03-01 09:12
Beserious
阅读(101)
推荐(0) 编辑
leetcode 598. Range Addition II
摘要:Given an m n matrix M initialized with all 0's and several update operations. Operations are represented by a 2D array, and each operation is represen
阅读全文
posted @
2018-03-01 09:09
Beserious
阅读(99)
推荐(0) 编辑
leetcode 599. Minimum Index Sum of Two Lists
摘要:Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to h
阅读全文
posted @
2018-03-01 09:05
Beserious
阅读(93)
推荐(0) 编辑
leetcode 606. Construct String from Binary Tree
摘要:You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be rep
阅读全文
posted @
2018-03-01 08:59
Beserious
阅读(99)
推荐(0) 编辑
leetcode 690. Employee Importance
摘要:You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates' id.
阅读全文
posted @
2018-03-01 08:53
Beserious
阅读(112)
推荐(0) 编辑
leetcode 404. Sum of Left Leaves
摘要:Find the sum of all left leaves in a given binary tree. 思路:在递归的时候访问左右节点记录一下,比如做节点标记1,右节点标2,那么当遍历到叶子节点的时候,我们只加标记为1的叶子节点的值。
阅读全文
posted @
2018-02-28 19:39
Beserious
阅读(51)
推荐(0) 编辑
leetcode 263. Ugly Number
摘要:Write 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 exa
阅读全文
posted @
2018-02-28 19:34
Beserious
阅读(83)
推荐(0) 编辑
leetcode 278. First Bad Version
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c
阅读全文
posted @
2018-02-28 19:33
Beserious
阅读(91)
推荐(0) 编辑
leetcode 303. Range Sum Query - Immutable
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. 前缀和思想。如果修改的次数比较多,那么就可以用线段树了, class NumArray { pu
阅读全文
posted @
2018-02-28 19:29
Beserious
阅读(84)
推荐(0) 编辑
leetcode 326. Power of Three
摘要:Given an integer, write a function to determine if it is a power of three. 判断一个数,是不是3的n次幂。直接换底公式求解
阅读全文
posted @
2018-02-28 19:22
Beserious
阅读(86)
推荐(0) 编辑
leetcode 350. Intersection of Two Arrays II
摘要:Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each eleme
阅读全文
posted @
2018-02-28 19:07
Beserious
阅读(97)
推荐(0) 编辑
leetcode 371. Sum of Two Integers
摘要:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and . Example: Given a = 1 and b = 2, return 3. 不用加减法进行求和运算。
阅读全文
posted @
2018-02-28 19:03
Beserious
阅读(104)
推荐(0) 编辑
leetcode 237. Delete Node in a Linked List
摘要:Write 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 y
阅读全文
posted @
2018-02-28 18:25
Beserious
阅读(82)
推荐(0) 编辑
leetcode 367. Valid Perfect Square
摘要:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built in library functio
阅读全文
posted @
2018-02-28 18:23
Beserious
阅读(123)
推荐(0) 编辑
leetcode 234. Palindrome Linked List
摘要:Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 判断一个链表是不是回文的。 思路:遍历节点得到总数tot,然后反转
阅读全文
posted @
2018-02-28 18:21
Beserious
阅读(105)
推荐(0) 编辑
leetcode 232. Implement Queue using Stacks
摘要:Implement the following operations of a queue using stacks. push(x) Push element x to the back of queue. pop() Removes the element from in front of qu
阅读全文
posted @
2018-02-28 18:16
Beserious
阅读(131)
推荐(0) 编辑
leetcode 225. Implement Stack using Queues
摘要:Implement the following operations of a stack using queues. push(x) Push element x onto stack. pop() Removes the element on top of the stack. top() Ge
阅读全文
posted @
2018-02-28 18:14
Beserious
阅读(129)
推荐(0) 编辑
leetcode 206. Reverse Linked List
摘要:Reverse a singly linked list. 思路:递归,每次保存一下上一个节点用来构造反转后的链表。 非递归,需要多记录两个值.
阅读全文
posted @
2018-02-28 18:09
Beserious
阅读(90)
推荐(0) 编辑