随笔分类 -  Algorithm

上一页 1 2 3 4 5 6 7 8 ··· 10 下一页
摘要:Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the s 阅读全文
posted @ 2020-07-27 11:46 Review->Improve 阅读(1083) 评论(0) 推荐(0)
摘要:Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers? Example 1: Input: 5 Output: 2 Explanation: 5 = 5 阅读全文
posted @ 2020-07-25 07:56 Review->Improve 阅读(407) 评论(0) 推荐(0)
摘要:Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justif 阅读全文
posted @ 2020-07-25 00:00 Review->Improve 阅读(792) 评论(0) 推荐(0)
摘要:Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions: The substr 阅读全文
posted @ 2020-07-22 07:09 Review->Improve 阅读(1032) 评论(0) 推荐(0)
摘要:Given a positive integer a, find the smallest positive integer b whose multiplication of each digit equals to a. If there is no answer or the answer i 阅读全文
posted @ 2020-07-10 01:34 Review->Improve 阅读(443) 评论(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 @ 2020-06-22 03:35 Review->Improve 阅读(445) 评论(0) 推荐(0)
摘要:Given the array houses and an integer k. where houses[i] is the location of the ith house along a street, your task is to allocate k mailboxes in the 阅读全文
posted @ 2020-06-20 05:37 Review->Improve 阅读(691) 评论(0) 推荐(0)
摘要:Given an array of integers arr and an integer target. You have to find two non-overlapping sub-arrays of arr each with sum equal target. There can be 阅读全文
posted @ 2020-06-18 22:33 Review->Improve 阅读(2072) 评论(0) 推荐(0)
摘要:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the pers 阅读全文
posted @ 2020-06-13 06:39 Review->Improve 阅读(255) 评论(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 @ 2020-06-11 07:57 Review->Improve 阅读(205) 评论(0) 推荐(0)
摘要:Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K. If there is no non-empty subarray with sum at least K, ret 阅读全文
posted @ 2020-06-11 07:49 Review->Improve 阅读(417) 评论(0) 推荐(0)
摘要:Given an array nums of integers, we need to find the maximum possible sum of elements of the array such that it is divisible by three. Example 1: Inpu 阅读全文
posted @ 2020-06-10 08:07 Review->Improve 阅读(725) 评论(0) 推荐(0)
摘要:There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th p 阅读全文
posted @ 2020-06-04 02:24 Review->Improve 阅读(252) 评论(0) 推荐(0)
摘要:There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have direct prerequisites, for example, to take course 0 you 阅读全文
posted @ 2020-05-31 10:49 Review->Improve 阅读(795) 评论(0) 推荐(0)
摘要:Given preorder and inorder traversal of a tree, construct the binary tree. You may assume that duplicates do not exist in the tree. Example Given in-o 阅读全文
posted @ 2020-05-28 02:25 Review->Improve 阅读(390) 评论(0) 推荐(0)
摘要:Return the lexicographically smallest subsequence of text that contains all the distinct characters of text exactly once. Example 1: Input: "cdadabcc" 阅读全文
posted @ 2020-05-27 12:20 Review->Improve 阅读(306) 评论(0) 推荐(0)
摘要:Given many words, words[i] has weight i. Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix). It will ret 阅读全文
posted @ 2020-05-27 06:54 Review->Improve 阅读(300) 评论(0) 推荐(0)
摘要:Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks coul 阅读全文
posted @ 2020-05-27 03:13 Review->Improve 阅读(259) 评论(0) 推荐(0)
摘要:Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Input: [0,1] Output: 2 Explanation: [0 阅读全文
posted @ 2020-05-26 22:23 Review->Improve 阅读(291) 评论(0) 推荐(0)
摘要:Given an array of integers and a number k, the majority number is the number that occurs more than 1/k of the size of the array, find all the majority 阅读全文
posted @ 2020-05-22 06:29 Review->Improve 阅读(189) 评论(0) 推荐(0)

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