Python3解leetcode Reach a Number
摘要:问题描述: You are standing at position 0 on an infinite number line. There is a goal at position target. On each move, you can either go left or right. Du
阅读全文
posted @
2019-09-24 14:55
狂奔的蜗牛163
阅读(293)
推荐(0)
Python3解leetcode Min Cost Climbing Stairs
摘要:问题描述: On a staircase, the i-th step has some non-negative cost cost[i]assigned (0 indexed). Once you pay the cost, you can either climb one or two ste
阅读全文
posted @
2019-09-23 15:30
狂奔的蜗牛163
阅读(281)
推荐(0)
Python3解leetcode Kth Largest Element in a Stream
摘要:问题描述: Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct el
阅读全文
posted @
2019-09-20 14:36
狂奔的蜗牛163
阅读(328)
推荐(0)
Python3解leetcode Count Binary Substrings
摘要:问题描述: Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's
阅读全文
posted @
2019-09-20 10:26
狂奔的蜗牛163
阅读(324)
推荐(0)
Python3解leetcode Average of Levels in Binary Tree
摘要:问题描述: Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: 思路: 考虑BFS算法,因为这是第一次碰到BFS算
阅读全文
posted @
2019-09-18 10:38
狂奔的蜗牛163
阅读(270)
推荐(0)
Python3解leetcode Subtree of Another Tree
摘要:问题描述: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of
阅读全文
posted @
2019-09-16 09:09
狂奔的蜗牛163
阅读(324)
推荐(0)
Python3解leetcode Number of Boomerangs
摘要:问题描述: Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between i and je
阅读全文
posted @
2019-08-07 20:14
狂奔的蜗牛163
阅读(298)
推荐(0)
Python3解leetcode 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 qua
阅读全文
posted @
2019-08-07 11:27
狂奔的蜗牛163
阅读(305)
推荐(0)
Python3解leetcode Path Sum III
摘要:问题描述: You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not
阅读全文
posted @
2019-08-07 10:37
狂奔的蜗牛163
阅读(367)
推荐(0)
Python3解leetcode N-ary Tree Level Order Traversal
摘要:问题描述: Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary
阅读全文
posted @
2019-08-06 14:08
狂奔的蜗牛163
阅读(298)
推荐(0)
Python3解leetcode Binary Tree PathsAdd DigitsMove Zeroes
摘要:问题描述: Given 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. Example: N
阅读全文
posted @
2019-07-17 14:13
狂奔的蜗牛163
阅读(176)
推荐(0)
Python3解leetcode Binary Tree PathsAdd Digits
摘要:问题描述: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: Follow up:Could you do it without
阅读全文
posted @
2019-07-16 15:06
狂奔的蜗牛163
阅读(241)
推荐(0)
Python3解leetcode Binary Tree Paths
摘要:问题描述: Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: 思路: 二叉树的问题,首先考虑递归算法,用深度优先搜索。 为了体现模块化思想,一般讲
阅读全文
posted @
2019-07-15 19:54
狂奔的蜗牛163
阅读(234)
推荐(0)
Python3解leetcode Lowest Common Ancestor of a Binary Search Tree
摘要:问题描述: Given 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 Wik
阅读全文
posted @
2019-07-11 07:42
狂奔的蜗牛163
阅读(298)
推荐(0)
Python3解leetcode Isomorphic Strings
摘要:问题描述: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occ
阅读全文
posted @
2019-07-09 16:27
狂奔的蜗牛163
阅读(169)
推荐(0)
Python3解leetcode Count Primes
摘要:问题描述: Count the number of prime numbers less than a non-negative number, n. Example: 思路: 1、最暴力的方法就是循环遍历,用两个for循环嵌套实现,但是整个代码运行时间太长,提交通不过 2、采用'Sieve of
阅读全文
posted @
2019-07-09 10:13
狂奔的蜗牛163
阅读(274)
推荐(0)
Python3解leetcode Maximum SubarrayHouse Robber
摘要:问题描述: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopp
阅读全文
posted @
2019-07-03 16:10
狂奔的蜗牛163
阅读(180)
推荐(0)
Python3解leetcode Rotate Array
摘要:问题描述: Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Example 2: Note: Try to come up as many solutions
阅读全文
posted @
2019-07-01 08:55
狂奔的蜗牛163
阅读(214)
推荐(0)
Python3解leetcode Factorial Trailing Zeroes
摘要:问题描述: Given an integer n, return the number of trailing zeroes in n!. Example 1: Example 2: Note: Your solution should be in logarithmic time complexi
阅读全文
posted @
2019-06-30 15:10
狂奔的蜗牛163
阅读(282)
推荐(0)
Python3解leetcode Linked List Cycle
摘要:问题描述: Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer poswhich represents the
阅读全文
posted @
2019-06-25 08:42
狂奔的蜗牛163
阅读(259)
推荐(0)