随笔分类 -  leetcode

rotate list
摘要:Given a list, rotate the list to the right by k places, where k is non-negative. Example: 题目是要求从后往前的第k个节点旋转。这里的4.我们要做的就是:1、将一个指针移到最后节点。2、将另一个指针移到旋转点的前 阅读全文

posted @ 2018-01-06 10:14 夜的第八章 阅读(121) 评论(0) 推荐(0)

Set Matrix Zeroes
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra sp 阅读全文

posted @ 2018-01-05 20:28 夜的第八章 阅读(166) 评论(0) 推荐(0)

Remove Duplicates from Sorted Array II
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array nums = [1,1,1,2,2,3], Your function sho 阅读全文

posted @ 2018-01-05 18:47 夜的第八章 阅读(115) 评论(0) 推荐(0)

spiral matrix II
摘要:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3, You should return the followi 阅读全文

posted @ 2018-01-05 16:02 夜的第八章 阅读(123) 评论(0) 推荐(0)

merge intervals(合并间隔)
摘要:Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]. 题目没有说所有间隔的 阅读全文

posted @ 2018-01-05 15:16 夜的第八章 阅读(227) 评论(0) 推荐(0)

jump game
摘要: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 阅读全文

posted @ 2018-01-04 19:32 夜的第八章 阅读(151) 评论(0) 推荐(0)

spiral matrix 螺旋矩阵
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,Given the following matrix: You s 阅读全文

posted @ 2018-01-04 16:56 夜的第八章 阅读(306) 评论(0) 推荐(0)

pow(x,n)
摘要:Implement pow(x, n). Example 1: Example 2: 实现x^n。这里要注意的是n为负数的情况。n为负数时也可以将n转成正数,这样x=1/x。。代码用了另一种方法,见代码。 阅读全文

posted @ 2018-01-03 19:13 夜的第八章 阅读(153) 评论(0) 推荐(0)

minimun path sum(最小路径和)
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文

posted @ 2018-01-03 15:43 夜的第八章 阅读(242) 评论(0) 推荐(0)

unique paths II
摘要:Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space 阅读全文

posted @ 2018-01-03 14:58 夜的第八章 阅读(129) 评论(0) 推荐(0)

combination sum、permutation、subset(组合和、全排列、子集)
摘要:combination sum I、permutation I、subsets I 是组合和、全排列、子集的第一种情况,给定数组中没有重复的元素。 combination sum II、permutation II、subsets II 是组合和、全排列、子集的第而种情况,给定数组中有重复元素。 c 阅读全文

posted @ 2018-01-03 12:56 夜的第八章 阅读(455) 评论(0) 推荐(0)

subsets II
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta 阅读全文

posted @ 2018-01-03 12:22 夜的第八章 阅读(123) 评论(0) 推荐(0)

subsets(子集)
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. For ex 阅读全文

posted @ 2018-01-03 11:01 夜的第八章 阅读(160) 评论(0) 推荐(0)

combinations(组合)
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: 从1,。。。,n中选出k个 阅读全文

posted @ 2018-01-02 21:59 夜的第八章 阅读(191) 评论(0) 推荐(0)

Group Anagrams 群组错位词
摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: Note: All inputs will be i 阅读全文

posted @ 2018-01-02 21:27 夜的第八章 阅读(156) 评论(0) 推荐(0)

rotate image(旋转数组)
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note:You have to rotate the image in-place, which 阅读全文

posted @ 2018-01-02 20:28 夜的第八章 阅读(182) 评论(0) 推荐(0)

permutations II(全排列 2)
摘要:题目要求 对于其基础题PermutationsI请参考我的另一篇博客这里添加的难度在于,排列组合的数字中可能存在重复。这就需要想方法,将结果集中重复的结果删去。而这里,我参考了另一名答题者的答案,在试图将数字添入结果集中时,就判断会不会产生重复的结果,从而使避免重复。 PermutationsI也可 阅读全文

posted @ 2018-01-02 19:46 夜的第八章 阅读(1197) 评论(0) 推荐(0)

multiply Strings
摘要:参考:https://www.cnblogs.com/TenosDoIt/p/3735309.html Given two numbers represented as strings, return multiplication of the numbers as a string. Note: 阅读全文

posted @ 2018-01-02 16:31 夜的第八章 阅读(116) 评论(0) 推荐(0)

unique paths
摘要: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 @ 2017-12-29 16:10 夜的第八章 阅读(203) 评论(0) 推荐(0)

search for a range(找出一个数在数组中开始和结束位置)
摘要:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexi 阅读全文

posted @ 2017-12-28 17:24 夜的第八章 阅读(477) 评论(0) 推荐(0)

导航