随笔分类 -  Leetcode

摘要:Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If the 阅读全文
posted @ 2018-11-08 16:34 Veritas_des_Liberty 阅读(244) 评论(0) 推荐(0) 编辑
摘要:For an integer n, we call k>=2 a good base of n, if all digits of n base k are 1. Now given a string representing n, you should return the smallest go 阅读全文
posted @ 2018-11-07 21:33 Veritas_des_Liberty 阅读(324) 评论(0) 推荐(0) 编辑
摘要:Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses. Now, you are given p 阅读全文
posted @ 2018-11-07 20:39 Veritas_des_Liberty 阅读(268) 评论(0) 推荐(0) 编辑
摘要:Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make pro 阅读全文
posted @ 2018-11-07 19:29 Veritas_des_Liberty 阅读(214) 评论(0) 推荐(0) 编辑
摘要:You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number 阅读全文
posted @ 2018-11-06 21:55 Veritas_des_Liberty 阅读(215) 评论(0) 推荐(0) 编辑
摘要:Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point o 阅读全文
posted @ 2018-11-06 21:38 Veritas_des_Liberty 阅读(202) 评论(0) 推荐(0) 编辑
摘要:Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algor 阅读全文
posted @ 2018-11-06 20:28 Veritas_des_Liberty 阅读(177) 评论(0) 推荐(0) 编辑
摘要:Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is po 阅读全文
posted @ 2018-11-05 17:01 Veritas_des_Liberty 阅读(192) 评论(0) 推荐(0) 编辑
摘要:Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is th 阅读全文
posted @ 2018-11-05 12:11 Veritas_des_Liberty 阅读(157) 评论(0) 推荐(0) 编辑
摘要:We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2018-11-05 09:39 Veritas_des_Liberty 阅读(159) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio 阅读全文
posted @ 2018-11-05 09:24 Veritas_des_Liberty 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k. Example: Not 阅读全文
posted @ 2018-11-04 22:33 Veritas_des_Liberty 阅读(269) 评论(0) 推荐(0) 编辑
摘要:You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the w 阅读全文
posted @ 2018-11-04 11:08 Veritas_des_Liberty 阅读(266) 评论(0) 推荐(0) 编辑
摘要:A peak element is an element that is greater than its neighbors. Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return 阅读全文
posted @ 2018-11-03 22:38 Veritas_des_Liberty 阅读(220) 评论(0) 推荐(0) 编辑
摘要:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. 阅读全文
posted @ 2018-11-03 22:21 Veritas_des_Liberty 阅读(172) 评论(0) 推荐(0) 编辑
摘要:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 阅读全文
posted @ 2018-11-03 17:16 Veritas_des_Liberty 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted i 阅读全文
posted @ 2018-11-03 15:36 Veritas_des_Liberty 阅读(174) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2018-11-02 22:37 Veritas_des_Liberty 阅读(176) 评论(0) 推荐(0) 编辑
摘要:code C // Forward declaration of isBadVersion API. bool isBadVersion(int version); class Solution { public: int firstBadVersion(int n) { int l = 1; in 阅读全文
posted @ 2018-11-01 18:47 Veritas_des_Liberty 阅读(143) 评论(0) 推荐(0) 编辑
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c 阅读全文
posted @ 2018-11-01 18:04 Veritas_des_Liberty 阅读(150) 评论(0) 推荐(0) 编辑