随笔分类 -  算法题

摘要:Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia:In a complete binary tree every lev 阅读全文
posted @ 2019-05-05 09:37 小白兔云 阅读(128) 评论(0) 推荐(0)
摘要: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 @ 2019-04-29 15:47 小白兔云 阅读(119) 评论(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 @ 2019-04-29 10:39 小白兔云 阅读(128) 评论(0) 推荐(0)
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are ar 阅读全文
posted @ 2019-04-28 14:20 小白兔云 阅读(120) 评论(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. Example 阅读全文
posted @ 2019-04-28 11:12 小白兔云 阅读(132) 评论(0) 推荐(0)
摘要:Design a data structure that supports the following two operations: search(word) can search a literal word or a regular expression string containing o 阅读全文
posted @ 2019-04-28 10:36 小白兔云 阅读(132) 评论(0) 推荐(0)
摘要:Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns 阅读全文
posted @ 2019-04-26 15:09 小白兔云 阅读(168) 评论(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 to 阅读全文
posted @ 2019-04-26 11:49 小白兔云 阅读(128) 评论(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 @ 2019-04-26 11:18 小白兔云 阅读(137) 评论(0) 推荐(0)
摘要:Given a list of non negative integers, arrange them such that they form the largest number. Example 1: Example 2: 题目大意: 返回非负数数组数字组成的最大数字 解法: 利用java中自带 阅读全文
posted @ 2019-04-25 17:33 小白兔云 阅读(125) 评论(0) 推荐(0)
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to 阅读全文
posted @ 2019-04-25 17:30 小白兔云 阅读(128) 评论(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 to 阅读全文
posted @ 2019-04-25 17:17 小白兔云 阅读(148) 评论(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 @ 2019-04-24 17:07 小白兔云 阅读(103) 评论(0) 推荐(0)
摘要:Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. Example 1: Example 2: 题目大意: 返回[m 阅读全文
posted @ 2019-04-24 15:38 小白兔云 阅读(110) 评论(0) 推荐(0)
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen 阅读全文
posted @ 2019-04-24 15:02 小白兔云 阅读(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. Example 阅读全文
posted @ 2019-04-24 14:54 小白兔云 阅读(92) 评论(0) 推荐(0)
摘要:恢复内容开始 Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is re 阅读全文
posted @ 2019-04-23 21:23 小白兔云 阅读(123) 评论(0) 推荐(0)
摘要:Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0. You may assume 阅读全文
posted @ 2019-04-23 19:34 小白兔云 阅读(111) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: E 阅读全文
posted @ 2019-04-22 20:57 小白兔云 阅读(106) 评论(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 @ 2019-04-22 20:20 小白兔云 阅读(183) 评论(0) 推荐(0)