![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 68
lililydia
以后再填吧
展开
-
leetcode11_盛最多水的容器
题目:给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点(i,ai) 。在坐标内画 n 条垂直线,垂直线 i的两个端点分别为(i,ai) 和 (i, 0)。找出其中的两条线,使得它们与x轴共同构成的容器可以容纳最多的水。说明:你不能倾斜容器,且n的值至少为 2。图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容...原创 2019-10-24 23:12:51 · 156 阅读 · 0 评论 -
leetcode125_Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palindrome.Examp...原创 2019-02-24 12:05:53 · 67 阅读 · 0 评论 -
leetcode141_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 position (0-indexed) in the linked list where tail con...原创 2019-02-24 12:06:10 · 62 阅读 · 0 评论 -
leetcode122_Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy on...原创 2019-02-24 12:05:49 · 44 阅读 · 0 评论 -
leetcode169_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 element alwa...原创 2019-02-24 12:06:56 · 84 阅读 · 0 评论 -
leetcode168_Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -&g...原创 2019-02-24 12:06:43 · 71 阅读 · 0 评论 -
leetcode167_Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers ...原创 2019-02-24 12:06:39 · 120 阅读 · 0 评论 -
leetcode121_Best Time to Buy and Sell Stock
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),...原创 2019-02-24 12:05:35 · 50 阅读 · 0 评论 -
leetcode119_Pascal's Triangle II
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.Note that the row index starts from 0.In Pascal's triangle, each number is the sum of the two numbers ...原创 2019-02-24 12:05:31 · 73 阅读 · 0 评论 -
leetcode118_Pascal's Triangle
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:...原创 2019-02-24 12:05:15 · 64 阅读 · 0 评论 -
leetcode112_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-02-24 12:05:06 · 150 阅读 · 0 评论 -
leetcode111_Minimum Depth of Binary Tree
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 childre...原创 2019-02-24 12:02:58 · 63 阅读 · 0 评论 -
leetcode110_Balanced 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-02-24 12:02:19 · 67 阅读 · 0 评论 -
leetcode155_Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Ge...原创 2019-02-24 12:06:24 · 86 阅读 · 0 评论 -
leetcode160_Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1. Example 1:Input: ...原创 2019-02-24 12:06:27 · 63 阅读 · 0 评论 -
leetcode205_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 occurrences of a character must be replaced wit...原创 2019-02-24 12:08:19 · 88 阅读 · 0 评论 -
leetcode204_Count Primes
Count the number of prime numbers less than a non-negative number, n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.一开始写了一个双层遍历的类型,具体如下:c...原创 2019-02-24 12:08:01 · 119 阅读 · 0 评论 -
leetcode203_Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.Example:Input: 1->2->6->3->4->5->6, val = 6Output: 1->2->3->4->5题意是:删除链表中等于给定值 val 的所有节点。...原创 2019-02-24 12:07:56 · 62 阅读 · 0 评论 -
leetcode202_Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o...原创 2019-02-24 12:07:46 · 73 阅读 · 0 评论 -
leetcode198_House 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 stopping you from robbing each of them is that adjacent house...原创 2019-02-24 12:07:42 · 67 阅读 · 0 评论 -
leetcode190_Reverse Bits
Reverse bits of a given 32 bits unsigned integer. Example 1:Input: 00000010100101000001111010011100Output: 00111001011110000010100101000000Explanation: The input binary string 000000101001010...原创 2019-02-24 12:07:27 · 68 阅读 · 0 评论 -
leetcode189_Rotate Array
Given an array, rotate the array to the right by k steps, where k is non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to the right: [7,1...原创 2019-02-24 12:07:14 · 65 阅读 · 0 评论 -
leetcode172_Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Example 1:Input: 3Output: 0Explanation: 3! = 6, no trailing zero.Example 2:Input: 5Output: 1Explanation: 5! = 120, one trai...原创 2019-02-24 12:07:10 · 147 阅读 · 0 评论 -
leetcode191_Number of 1 Bits
Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example 1:Input: 00000000000000000000000000001011Output: 3Explanat...原创 2019-02-24 12:07:31 · 113 阅读 · 0 评论 -
leetcode136_Single Number
Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without us...原创 2019-02-24 12:06:06 · 110 阅读 · 0 评论 -
leetcode171_Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> ...原创 2019-02-24 12:06:59 · 64 阅读 · 0 评论 -
leetcode108_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 the...原创 2019-02-24 12:02:44 · 72 阅读 · 0 评论 -
leetcode107_Binary Tree Level Order Traversal II
107. Binary Tree Level Order Traversal IIEasy56398FavoriteShareGiven a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from ...原创 2019-02-24 11:59:51 · 110 阅读 · 0 评论 -
leetcode38_Count and Say
The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 is read o...原创 2019-02-24 11:58:13 · 124 阅读 · 0 评论 -
leetcode7_Reverse Integer
问题描述: 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...原创 2019-02-24 11:56:35 · 126 阅读 · 0 评论 -
LeetCode69_Sqrt(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 dec...原创 2019-02-24 12:03:36 · 97 阅读 · 0 评论 -
LeetCode35_Search Insert Position
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...原创 2019-02-24 11:58:09 · 74 阅读 · 0 评论 -
LeetCode28_Implement 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...原创 2019-02-24 11:58:04 · 79 阅读 · 0 评论 -
leetcode1-TwoSum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sa...原创 2019-02-24 11:56:20 · 81 阅读 · 0 评论 -
用python批量获取某路径文件夹及子文件夹下的指定类型文件,并按原文件夹结构批量存储处理后的文件
因为是把自己成功运行的整个代码按几部分截取出来的,所以每一小节不一定能单独运行,特此说明。1.获取某路径文件夹及子文件夹下的指定pcm类型文件的全部路径import osdef eachfile(filepath): pathdir=os.listdir(filepath) for s in pathdir: newdir = os.path.join(file...原创 2018-07-02 22:40:19 · 4067 阅读 · 0 评论 -
LeetCode27_Remove Element
这道题并不要求输出数组的顺序,所以难度降低了不少。 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 th...原创 2019-02-24 11:57:48 · 70 阅读 · 0 评论 -
LeetCode26_Remove Duplicates from Sorted Array
这道题给的是排好序之后的数组,所以难度降低不少。但要注意审题。Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another a...原创 2019-02-24 11:57:44 · 81 阅读 · 0 评论 -
LeetCode21_Merge Two Sorted Lists
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-...原创 2019-02-24 12:04:41 · 70 阅读 · 0 评论 -
LeetCode20_Valid Parentheses
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 b...原创 2019-02-24 12:04:34 · 81 阅读 · 0 评论 -
leetcode70_Climbing Stairs
可能自己就是一个没什么逻辑思维的人,所以看到这个题只觉得想不到思路。。。所以先参考了别人的想法。。。参考文章链接为https://blog.csdn.net/sanmao0816/article/details/44704327具体题目如下:You are climbing a stair case. It takes n steps to reach to the top.Eac...原创 2019-02-24 12:03:31 · 79 阅读 · 0 评论