随笔分类 -  algorithm

上一页 1 2 3 4 5 6 7 8 ··· 13 下一页
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not po ssi 阅读全文
posted @ 2017-12-29 07:26 逸朵 阅读(140) 评论(0) 推荐(0)
摘要:1 public class BinarySearchSolution 2 { 3 public int BinarySearch(int[] array, int target) 4 { 5 int low = 0, high = array.Length; ... 阅读全文
posted @ 2017-12-28 14:32 逸朵 阅读(144) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring T that contains at most k distinct characters. For example, Given s = “eceba” and k = 2, T is 阅读全文
posted @ 2017-12-28 13:37 逸朵 阅读(131) 评论(0) 推荐(0)
摘要:Note:A subtree must include all of its descendants.Here's an example: The Largest BST Subtree in this case is the highlighted one. The return value is 阅读全文
posted @ 2017-12-28 09:55 逸朵 阅读(152) 评论(0) 推荐(0)
摘要:Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. Note:The sum of 阅读全文
posted @ 2017-12-28 05:17 逸朵 阅读(464) 评论(0) 推荐(0)
摘要:Write a function to generate the generalized abbreviations of a word. Example: Given word = "word", return the following list (order does not matter): 阅读全文
posted @ 2017-12-28 04:30 逸朵 阅读(376) 评论(0) 推荐(0)
摘要:Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes are in the sam 阅读全文
posted @ 2017-12-28 01:46 逸朵 阅读(305) 评论(0) 推荐(0)
摘要:Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node to any 阅读全文
posted @ 2017-12-20 06:56 逸朵 阅读(130) 评论(0) 推荐(0)
摘要:Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a lette 阅读全文
posted @ 2017-12-20 06:17 逸朵 阅读(163) 评论(0) 推荐(0)
摘要:Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in 阅读全文
posted @ 2017-12-20 05:36 逸朵 阅读(169) 评论(0) 推荐(0)
摘要:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... For example, given nums = [3, 5, 2, 1, 6, 4], 阅读全文
posted @ 2017-12-20 04:59 逸朵 阅读(117) 评论(0) 推荐(0)
摘要:Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is tha 阅读全文
posted @ 2017-12-20 04:48 逸朵 阅读(180) 评论(0) 推荐(0)
摘要:Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list 阅读全文
posted @ 2017-12-20 04:33 逸朵 阅读(138) 评论(0) 推荐(0)
摘要:Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floati 阅读全文
posted @ 2017-12-20 03:49 逸朵 阅读(196) 评论(0) 推荐(0)
摘要:Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floati 阅读全文
posted @ 2017-12-20 03:23 逸朵 阅读(318) 评论(0) 推荐(0)
摘要:Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form 阅读全文
posted @ 2017-12-20 03:07 逸朵 阅读(288) 评论(0) 推荐(0)
摘要:There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. Yo 阅读全文
posted @ 2017-12-20 01:51 逸朵 阅读(117) 评论(0) 推荐(0)
摘要:Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges mak 阅读全文
posted @ 2017-12-19 09:06 逸朵 阅读(404) 评论(0) 推荐(0)
摘要:Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + 阅读全文
posted @ 2017-12-19 07:20 逸朵 阅读(142) 评论(0) 推荐(0)
摘要:There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certai 阅读全文
posted @ 2017-12-19 06:54 逸朵 阅读(147) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 ··· 13 下一页