随笔分类 - leetCode刷题经历
摘要:Given a sorted integer array without duplicates, return the summary of its ranges. Example 1: Example 2: 思路不难,从头到尾,从头到尾数数字,然后看是否连续就行, 这个答案是我在高票回答的评论中找
阅读全文
摘要:Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim
阅读全文
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib
阅读全文
摘要:这里强烈推荐一个博主写的二分搜索总结:http://www.cnblogs.com/grandyang/p/6854825.html 参考链接: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sort
阅读全文
摘要:这道题目很经典,本人表示在面试时遇见过,要求复杂度为O(logn),很显然必须用二分查找,但是旋转导致数组并非从左到右都是有序的,因此我们在查找时需要做判断,我们找打的终点左边或者右边至少一边是有序的;如果中间数小于最右边的数字,则右半段是有序的;如果中间数字大于最右边数字,则左半段是有序的,参考下
阅读全文
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [
阅读全文
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input:
阅读全文
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Op
阅读全文
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to le
阅读全文
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: T
阅读全文
摘要:In a string S of lowercase letters, these letters form consecutive groups of the same character. For example, a string like S = "abbxxxxzyy" has the g
阅读全文
摘要:821. Shortest Distance to a Character 821. Shortest Distance to a Character Given a string S and a character C, return an array of integers representi
阅读全文
摘要:Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found himself a new place for his thievery so tha
阅读全文
摘要: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 yo
阅读全文
摘要:今天手残,碰了一道leetcode HARD难度题目,果然来着不善,花了不少时间,题目很简单,求平面内一些离散点中,最大共线点的数量。最直接的思路就是通过斜率判断,但是考虑到斜率很可能是小数,比较小数的大小会有误差,因此我们不做除法,取横纵坐标差值的最大公约数,然后横纵坐标分别除以最大公约数即可,这
阅读全文
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e
阅读全文

浙公网安备 33010602011771号