
leetcode
文章平均质量分 59
MonkyK
这个作者很懒,什么都没留下…
展开
-
leetcode007-python 反转整数
Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dealing with an envir...原创 2018-06-23 14:48:33 · 301 阅读 · 0 评论 -
leetcode083-python 删除链表中重复元素
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that nums...原创 2018-06-28 21:10:10 · 559 阅读 · 0 评论 -
leetcode088-python 合并两个有序数组
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that nums...原创 2018-06-28 21:42:41 · 305 阅读 · 0 评论 -
leetcode101-python 对称二叉树
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the...原创 2018-07-04 14:15:52 · 988 阅读 · 0 评论 -
leetcode104-python 二叉树最大深度
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.Note: A leaf is a node with no children.Ex...原创 2018-07-04 19:19:45 · 1007 阅读 · 0 评论 -
leetcode107-python 二叉树层次遍历
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15,7], ...原创 2018-07-04 20:53:33 · 595 阅读 · 0 评论 -
leetcode-108 将有序数组转化为二叉搜索树
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the t...原创 2018-07-05 15:42:13 · 229 阅读 · 0 评论 -
leetcode110-python 平衡二叉树
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 differ by...原创 2018-07-05 16:46:55 · 1434 阅读 · 0 评论 -
leetcode111-python 二叉树的最小深度
Given 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.Note: A leaf is a node with no children.Ex...原创 2018-07-05 19:30:24 · 647 阅读 · 0 评论 -
leetcode112-python 路径总和
Given 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.Note: A leaf is a node with no children.Example:Give...原创 2018-07-05 20:16:42 · 508 阅读 · 0 评论 -
leetcode-118 python 杨辉三角
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:[ ...原创 2018-07-05 21:03:18 · 435 阅读 · 0 评论 -
leetcode070-python 爬楼梯
You 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?Note: Given n will be a positive int...原创 2018-06-27 19:39:00 · 589 阅读 · 0 评论 -
leetcode069-python x的平方根
Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only the...原创 2018-06-27 18:59:50 · 379 阅读 · 0 评论 -
leetcode067-python 二进制求和
Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = "11", b = "1"Output: "100"Example 2:Inp...原创 2018-06-27 18:41:04 · 413 阅读 · 0 评论 -
leetcode009-python 回文数
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseExplanation: F...原创 2018-06-23 15:33:04 · 990 阅读 · 0 评论 -
leetcode013-python 罗马数字转整数
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 5...原创 2018-06-23 17:53:47 · 541 阅读 · 0 评论 -
leetcode020-python 有效括号
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of brack...原创 2018-06-24 19:08:52 · 336 阅读 · 0 评论 -
leetcode021-python 合并有序链表
Merge 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.Example:Input: 1->2->4, 1->3->4Output: 1->1...原创 2018-06-24 20:34:40 · 366 阅读 · 2 评论 -
leetcode027-python 移除元素
Given an array nums and a value val, 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 by modifying the input array ...原创 2018-06-24 22:32:06 · 138 阅读 · 0 评论 -
leetcode100-python 相同的树
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example 1:In...原创 2018-06-29 16:10:44 · 352 阅读 · 0 评论 -
leetcode028-python 实现strStr()
Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:Input:...原创 2018-06-26 16:07:40 · 288 阅读 · 0 评论 -
leetcode035-python 搜索插入位置
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Exam...原创 2018-06-26 16:38:32 · 204 阅读 · 0 评论 -
leetcode058-python 最后一个单词长度
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined a...原创 2018-06-26 20:25:43 · 343 阅读 · 0 评论 -
leetcode066-python 加一
Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element i...原创 2018-06-26 22:20:32 · 192 阅读 · 0 评论 -
leetcode121-python 买卖股票最佳时机
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), d...原创 2018-07-07 17:51:06 · 377 阅读 · 0 评论