Fork me on GitHub

随笔分类 -  LeetCode

摘要:/** * Given a sorted linked list, delete all duplicates such that each element appear only once. * For example, * Given1->1->2, return1->2. * Given1->1->2->3->3, return1->2->3. * * 给定一个已排序的链接列表,删除所有重复 阅读全文
posted @ 2019-08-08 11:47 gentleKay 阅读(149) 评论(0) 推荐(0)
摘要:/** * Given a collection of numbers, return all possible permutations. * For example, * [1,2,3]have the following permutations: * [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2], and[3,2,1]. * * 给定一组数字,返回所有可能 阅读全文
posted @ 2019-08-08 11:47 gentleKay 阅读(224) 评论(0) 推荐(0)
摘要:参考资料:https://blog.csdn.net/snow_7/article/details/51815787 阅读全文
posted @ 2019-08-07 15:33 gentleKay 阅读(154) 评论(0) 推荐(0)
摘要:/** * 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 space? * A straight forward solution u... 阅读全文
posted @ 2019-08-07 10:22 gentleKay 阅读(182) 评论(0) 推荐(0)
摘要:/** * The count-and-say sequence is the sequence of integers beginning as follows: * 1, 11, 21, 1211, 111221, ... * 1is read off as"one 1"or11. * 11is read off as"two 1 s"or21. * 21is read off as"one ... 阅读全文
posted @ 2019-08-07 10:21 gentleKay 阅读(228) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given an array of non-negative integers, you are initially positioned at the first index of the array. * Each element in t 阅读全文
posted @ 2019-08-06 10:54 gentleKay 阅读(148) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is 阅读全文
posted @ 2019-08-06 10:53 gentleKay 阅读(228) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given a linked list, swap every two adjacent nodes and return its head. * For example, * Given1->2->3->4, you should retur 阅读全文
posted @ 2019-08-05 10:49 gentleKay 阅读(198) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. * 阅读全文
posted @ 2019-08-05 10:46 gentleKay 阅读(148) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. * For example, giv 阅读全文
posted @ 2019-08-02 11:13 gentleKay 阅读(348) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with t 阅读全文
posted @ 2019-08-02 11:12 gentleKay 阅读(187) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given a binary tree, return the preorder traversal of its nodes' values. * For example: * Given binary tree{1,#,2,3}, * 1 阅读全文
posted @ 2019-08-01 16:11 gentleKay 阅读(143) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given an array of integers, every element appears three times except for one. Find that single one. * Note: * Your algorit 阅读全文
posted @ 2019-08-01 15:12 gentleKay 阅读(268) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Merge two sorted linked lists and return it as a new list. * The new list should be made by splicing together the nodes of 阅读全文
posted @ 2019-08-01 15:08 gentleKay 阅读(160) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * You are given an n x n 2D matrix representing an image. * Rotate the image by 90 degrees (clockwise). * Follow up: * Could 阅读全文
posted @ 2019-07-31 15:40 gentleKay 阅读(269) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: * Int 阅读全文
posted @ 2019-07-31 15:33 gentleKay 阅读(143) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * The gray code is a binary numeral system where two successive values differ in only one bit. * Given a non-negative intege 阅读全文
posted @ 2019-07-31 15:31 gentleKay 阅读(317) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * You are climbing a stair case. It takes n steps to reach to the top. * Each time you can either climb 1 or 2 steps. In how 阅读全文
posted @ 2019-07-30 17:49 gentleKay 阅读(366) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given a binary tree, return the inorder traversal of its nodes' values. * For example: * Given binary tree{1,#,2,3}, 1 \ 2 阅读全文
posted @ 2019-07-30 17:41 gentleKay 阅读(139) 评论(0) 推荐(0)
摘要:/** * * @author gentleKay * Given a sorted array and a target value, return the index if the target is found. * If not, return the index where it woul 阅读全文
posted @ 2019-07-30 17:38 gentleKay 阅读(104) 评论(0) 推荐(0)