
LeetCode
liveway6
这个作者很懒,什么都没留下…
展开
-
LeetCode--448
448. Find All Numbers Disappeared in an Array题目概述Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inc原创 2017-03-01 20:47:44 · 476 阅读 · 1 评论 -
Leetcode: 101. Symmetric Tree
题目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 3B...原创 2019-07-16 13:09:23 · 114 阅读 · 0 评论 -
LeetCode: 109. Convert Sorted List to Binary Search Tree
题目Given a singly linked list 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 th...原创 2019-07-18 20:56:21 · 97 阅读 · 0 评论 -
Leetcode: 113. Path Sum II
题目Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.Note: A leaf is a node with no children.Example:Given the below binary tree and sum = 22, ...原创 2019-07-23 20:02:24 · 101 阅读 · 0 评论 -
LeetCode: 102. Binary Tree Level Order Traversal
题目Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 ...原创 2019-07-16 21:19:40 · 98 阅读 · 0 评论 -
Leetcode:114. Flatten Binary Tree to Linked List
题目Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2 \ 3 ...原创 2019-07-23 21:27:14 · 84 阅读 · 0 评论 -
LeetCode: 103. Binary Tree Zigzag Level Order Traversal
题目Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary t...原创 2019-07-17 13:03:21 · 102 阅读 · 0 评论 -
LeetCode: 104. 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.Note: A leaf is a node with no childr...原创 2019-07-17 13:11:05 · 170 阅读 · 0 评论 -
LeetCode: 105. Construct Binary Tree from Preorder and Inorder Traversal
题目Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, givenpreorder = [3,9,20,15,7]inorder = [9,3,...原创 2019-07-17 20:00:47 · 102 阅读 · 0 评论 -
LeetCode: 106. Construct Binary Tree from Inorder and Postorder Traversal
题目Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, giveninorder = [9,3,15,20,7]postorder = [9,...原创 2019-07-17 20:28:40 · 99 阅读 · 0 评论 -
LeetCode:115. Distinct Subsequences
题目Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleting some (...原创 2019-07-24 20:46:02 · 75 阅读 · 0 评论 -
LeetCode: 107. Binary Tree Level Order Traversal II
题目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...原创 2019-07-17 20:47:02 · 85 阅读 · 0 评论 -
LeetCode: 111. Minimum Depth of 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 diff...原创 2019-07-22 13:23:26 · 96 阅读 · 0 评论 -
Leetcode: 112. Path Sum
题目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...原创 2019-07-22 14:48:51 · 94 阅读 · 0 评论 -
剑指offer:合并两个排序的链表 python实现 合并K个排序的链表
题目题目描述输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。对应LeetCode21.解题思路暴力求解:新建一个链表;依次判断两个链表的大小,选择小的构建,直至结束。# -*- coding:utf-8 -*-# class ListNode:# def __init__(self, x):# self....原创 2019-08-13 13:52:34 · 1440 阅读 · 0 评论 -
LeedCode: 计算器专场
今天滴滴第一面遇到这道题,mark一下!初级版题目实现一个基本的计算器来计算一个简单的字符串表达式的值。字符串表达式仅包含非负整数,+, - ,*,/ 四种运算符和空格 。 整数除法仅保留整数部分。示例输入: "3+2*2"输出: 7输入: " 3/2 "输出: 1输入: " 3+5 / 2 "输出: 5解题思路用栈的思想实现,当op为‘+’、‘-’时,把数字放入...原创 2019-08-10 22:38:08 · 138 阅读 · 0 评论 -
LeetCode: 66. Plus One
070701题目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 eac...原创 2019-07-07 08:20:05 · 116 阅读 · 0 评论 -
LeetCode: 108. Convert Sorted Array to Binary Search Tree
题目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 t...原创 2019-07-18 12:55:10 · 105 阅读 · 0 评论 -
LeetCode--495
495. Teemo Attacking题目概述In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo’s attacking ascending time series towards Ash原创 2017-02-26 21:20:13 · 321 阅读 · 0 评论 -
LeetCode--485
485. Max Consecutive Ones题目概述Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:nput: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three di原创 2017-02-26 21:40:47 · 710 阅读 · 0 评论 -
LeetCode:14. Longest Common Prefix
两年硕士超快的鸭,又要准备秋招啦!0508第一题~题目Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: ["flower"...原创 2019-05-08 09:47:38 · 136 阅读 · 0 评论 -
LeetCode: 20. Valid Parentheses
0509第1题(虽然是08做的,但这会已经09了)题目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 c...原创 2019-05-09 00:10:00 · 114 阅读 · 0 评论 -
LeetCode: 38. Count and Say
0509第2题题目The count-and-say sequence is the sequence of integers with the first five terms as following:1112112111112211 is read off as “one 1” or 11.11 is read off as “two 1s...原创 2019-05-09 00:37:18 · 137 阅读 · 0 评论 -
LeetCode: 929. Unique Email Addresses
051301题目Every email consists of a local name and a domain name, separated by the @ sign.For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name.Besides low...原创 2019-05-13 23:59:29 · 494 阅读 · 0 评论 -
LeetCode:937. Reorder Log Files
051401题目You have an array of logs. Each log is a space delimited string of words.For each log, the first word in each log is an alphanumeric identifier. Then, either:Each word after the identifi...原创 2019-05-14 00:46:21 · 210 阅读 · 0 评论 -
LeetCode: 58. Length of Last Word
051101题目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 ...原创 2019-05-11 09:55:04 · 121 阅读 · 0 评论 -
LeetCode: 344. Reverse String
051102题目Write a function that reverses a string. The input string is given as an array of characters char[].Do not allocate extra space for another array, you must do this by modifying the input ar...原创 2019-05-11 10:28:17 · 119 阅读 · 0 评论 -
LeetCode:345. Reverse Vowels of a String
051103题目Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Input: "hello"Output: "holle"Example 2:Input: "leetcode"Output: "leotcede"我的解题思路这道题跟...原创 2019-05-11 11:09:03 · 130 阅读 · 0 评论 -
LeetCode:383. Ransom Note
051104题目Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the maga...原创 2019-05-11 12:13:07 · 177 阅读 · 0 评论 -
LeetCode: 387. First Unique Character in a String
051105题目Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note: Y...原创 2019-05-11 13:22:20 · 157 阅读 · 0 评论 -
LeetCode: 13. Roman to Integer
051106题目Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2019-05-11 14:07:47 · 118 阅读 · 0 评论 -
LeetCode:917. Reverse Only Letters
051201题目Given a string S, return the “reversed” string where all characters that are not a letter stay in the same place, and all letters reverse their positions.Example 1:Input: "ab-cd"Output: "...原创 2019-05-12 09:58:47 · 192 阅读 · 0 评论 -
LeetCode:925. Long Pressed Name
051202题目Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times.You examine the typed ...原创 2019-05-12 13:16:29 · 305 阅读 · 0 评论 -
LeetCode: 150:逆波兰表示法求值。
题目根据逆波兰表示法,求表达式的值。有效的运算符包括 +, -, *, / 。每个运算对象可以是整数,也可以是另一个逆波兰表达式。说明:整数除法只保留整数部分。给定逆波兰表达式总是有效的。换句话说,表达式总会得出有效数值且不存在除数为 0 的情况。例子输入: ["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5"...原创 2019-08-11 00:35:29 · 122 阅读 · 0 评论