随笔分类 -  Leetcode

上一页 1 2 3 4 5 6 ··· 12 下一页
leetcode 309. Best Time to Buy and Sell Stock with Cooldown
摘要: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 comple 阅读全文
posted @ 2018-03-23 23:55 Beserious 阅读(145) 评论(0) 推荐(0) 编辑
leetcode 714. Best Time to Buy and Sell Stock with Transaction Fee
摘要:Your are given an array of integers prices, for which the i th element is the price of a given stock on day i; and a non negative integer fee represen 阅读全文
posted @ 2018-03-23 23:47 Beserious 阅读(249) 评论(0) 推荐(0) 编辑
leetcode 32. Longest Valid Parentheses
摘要:Given a string containing just the characters and , find the length of the longest valid (well formed) parentheses substring. For , the longest valid 阅读全文
posted @ 2018-03-21 21:24 Beserious 阅读(112) 评论(0) 推荐(0) 编辑
leetcode 224. Basic Calculator
摘要:Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or 阅读全文
posted @ 2018-03-21 21:06 Beserious 阅读(113) 评论(0) 推荐(0) 编辑
leetcode 540. Single Element in a Sorted Array
摘要:Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element 阅读全文
posted @ 2018-03-21 20:16 Beserious 阅读(129) 评论(0) 推荐(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 bina 阅读全文
posted @ 2018-03-17 10:27 Beserious 阅读(121) 评论(0) 推荐(0) 编辑
leetcode 3. Longest Substring Without Repeating Characters
摘要:Given a string, find the length of the longest substring without repeating characters. 思路:用map维护区间内各个字母的数量,然后遇到已经访问过的就进行滑动区间,来得到符合条件的区间,然后求最大区间长度。 虽然时 阅读全文
posted @ 2018-03-17 10:21 Beserious 阅读(121) 评论(0) 推荐(0) 编辑
leetcode 84. Largest Rectangle in Histogram
摘要:Given n non negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文
posted @ 2018-03-13 22:36 Beserious 阅读(143) 评论(0) 推荐(0) 编辑
leetcode 338. Counting Bits
摘要:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and r 阅读全文
posted @ 2018-03-12 20:36 Beserious 阅读(171) 评论(0) 推荐(0) 编辑
leetcode 797. All Paths From Source to Target
摘要:Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N 1, and return them in any order. The graph is given as follo 阅读全文
posted @ 2018-03-11 20:36 Beserious 阅读(376) 评论(0) 推荐(0) 编辑
leetcode 796. Rotate String
摘要:We are given two strings, A and B. A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, 阅读全文
posted @ 2018-03-11 20:20 Beserious 阅读(283) 评论(0) 推荐(0) 编辑
leetcode 153. Find Minimum in Rotated Sorted Array
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find 阅读全文
posted @ 2018-03-10 21:32 Beserious 阅读(142) 评论(0) 推荐(0) 编辑
leeetcode 735. Asteroid Collision
摘要:We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign r 阅读全文
posted @ 2018-03-09 20:13 Beserious 阅读(173) 评论(0) 推荐(0) 编辑
leetcode 795. Number of Subarrays with Bounded Maximum
摘要:We are given an array A of positive integers, and two positive integers L and R (L R`的数字,那么此时就重新开始计数。思路很简单,但是实现起来..... 代码中b维护的是`& A, int L, int R) { i 阅读全文
posted @ 2018-03-08 18:57 Beserious 阅读(319) 评论(0) 推荐(0) 编辑
leetcode 792. Number of Matching Subsequences
摘要:Given string S and a dictionary of words words, find the number of words[i] that is a subsequence of S. 思路:先用vector记录每个字母出现的位置,然后遍历每个单词,如果每个字母的位置是递增的那 阅读全文
posted @ 2018-03-06 21:58 Beserious 阅读(341) 评论(0) 推荐(0) 编辑
leetcode 4. Median of Two Sorted Arrays
摘要:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh 阅读全文
posted @ 2018-03-01 21:30 Beserious 阅读(117) 评论(0) 推荐(0) 编辑
leetcode 334. Increasing Triplet Subsequence
摘要:Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: 阅读全文
posted @ 2018-03-01 11:20 Beserious 阅读(87) 评论(0) 推荐(0) 编辑
leetcode 459. Repeated Substring Pattern
摘要:Given a non empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may a 阅读全文
posted @ 2018-03-01 10:32 Beserious 阅读(94) 评论(0) 推荐(0) 编辑
leetcode 501. Find Mode in Binary Search Tree
摘要:Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is define 阅读全文
posted @ 2018-03-01 09:41 Beserious 阅读(106) 评论(0) 推荐(0) 编辑
leetcode 530. Minimum Absolute Difference in BST
摘要:Given a binary search tree with non negative values, find the minimum absolute difference between values of any two nodes. 题目大意,求bst树任意两点的最小绝对距离。 思路,中 阅读全文
posted @ 2018-03-01 09:34 Beserious 阅读(105) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 12 下一页