随笔分类 -  LeetCode

摘要: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 or 阅读全文
posted @ 2019-06-14 15:11 月半榨菜 阅读(69) 评论(0) 推荐(0)
摘要:Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime com 阅读全文
posted @ 2019-06-14 14:57 月半榨菜 阅读(76) 评论(0) 推荐(0)
摘要:Given a sorted (in ascending order) integer array nums of n elements and a targetvalue, write a function to search target in nums. If target exists, t 阅读全文
posted @ 2019-06-14 11:29 月半榨菜 阅读(85) 评论(0) 推荐(0)
摘要:Given an array of integers nums, sort the array in ascending order. Example 1: Example 2: Note: 排序 参考https://www.cnblogs.com/zhacai/p/11011961.html 阅读全文
posted @ 2019-06-13 16:34 月半榨菜 阅读(73) 评论(0) 推荐(0)
摘要:Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't 阅读全文
posted @ 2019-06-04 21:24 月半榨菜 阅读(101) 评论(0) 推荐(0)
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-05-29 09:28 月半榨菜 阅读(69) 评论(0) 推荐(0)
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-05-29 09:22 月半榨菜 阅读(91) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer 阅读全文
posted @ 2019-05-17 14:15 月半榨菜 阅读(93) 评论(0) 推荐(0)
摘要: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 symmet 阅读全文
posted @ 2019-04-09 19:45 月半榨菜 阅读(85) 评论(0) 推荐(0)
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the 阅读全文
posted @ 2019-04-07 13:46 月半榨菜 阅读(136) 评论(0) 推荐(0)
摘要:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct 阅读全文
posted @ 2019-04-06 18:00 月半榨菜 阅读(129) 评论(0) 推荐(0)
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen 阅读全文
posted @ 2019-04-06 17:03 月半榨菜 阅读(93) 评论(0) 推荐(0)
摘要:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文
posted @ 2019-04-06 15:17 月半榨菜 阅读(104) 评论(0) 推荐(0)
摘要:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee 阅读全文
posted @ 2019-04-06 13:25 月半榨菜 阅读(110) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Note: There may be more than one LIS combination, it 阅读全文
posted @ 2019-04-06 12:07 月半榨菜 阅读(141) 评论(0) 推荐(0)
摘要: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 feerepresent 阅读全文
posted @ 2019-04-05 17:41 月半榨菜 阅读(140) 评论(0) 推荐(0)
摘要: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 @ 2019-04-04 17:14 月半榨菜 阅读(114) 评论(0) 推荐(0)
摘要: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 @ 2019-04-02 21:42 月半榨菜 阅读(108) 评论(0) 推荐(0)
摘要: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 @ 2019-04-02 21:36 月半榨菜 阅读(126) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: E 阅读全文
posted @ 2019-04-02 17:38 月半榨菜 阅读(85) 评论(0) 推荐(0)