随笔分类 -  algorithm

上一页 1 ··· 4 5 6 7 8 9 10 11 12 13 下一页
摘要:Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and 阅读全文
posted @ 2017-12-02 07:58 逸朵 阅读(161) 评论(0) 推荐(0)
摘要:Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be 阅读全文
posted @ 2017-12-02 06:38 逸朵 阅读(151) 评论(0) 推荐(0)
摘要:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam 阅读全文
posted @ 2017-12-02 05:42 逸朵 阅读(164) 评论(0) 推荐(0)
摘要:Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can f 阅读全文
posted @ 2017-12-02 01:23 逸朵 阅读(132) 评论(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 @ 2017-11-29 12:53 逸朵 阅读(153) 评论(0) 推荐(0)
摘要:There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have t 阅读全文
posted @ 2017-11-29 12:39 逸朵 阅读(197) 评论(0) 推荐(0)
摘要:There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have t 阅读全文
posted @ 2017-11-29 09:18 逸朵 阅读(145) 评论(0) 推荐(0)
摘要:Description: Count the number of prime numbers less than a non-negative number, n. 阅读全文
posted @ 2017-11-29 07:24 逸朵 阅读(137) 评论(0) 推荐(0)
摘要:Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5, 阅读全文
posted @ 2017-11-29 07:03 逸朵 阅读(125) 评论(0) 推荐(0)
摘要:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For exa 阅读全文
posted @ 2017-11-29 06:07 逸朵 阅读(104) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-11-29 05:58 逸朵 阅读(96) 评论(0) 推荐(0)
摘要:Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed n 阅读全文
posted @ 2017-11-29 05:33 逸朵 阅读(126) 评论(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 @ 2017-11-29 01:43 逸朵 阅读(133) 评论(0) 推荐(0)
摘要:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the n 阅读全文
posted @ 2017-11-29 01:24 逸朵 阅读(113) 评论(0) 推荐(0)
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 阅读全文
posted @ 2017-11-23 08:20 逸朵 阅读(134) 评论(0) 推荐(0)
摘要:Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assum 阅读全文
posted @ 2017-11-23 08:08 逸朵 阅读(157) 评论(0) 推荐(0)
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find 阅读全文
posted @ 2017-11-23 04:59 逸朵 阅读(140) 评论(0) 推荐(0)
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find 阅读全文
posted @ 2017-11-23 04:54 逸朵 阅读(139) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4],t 阅读全文
posted @ 2017-11-23 04:35 逸朵 阅读(99) 评论(0) 推荐(0)
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e 阅读全文
posted @ 2017-11-23 04:17 逸朵 阅读(124) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 13 下一页