随笔分类 - Leetcode
摘要:Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyza
阅读全文
摘要:In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue. For now, suppose you are a domin
阅读全文
摘要:Define S = [s,n] as the string S which consists of n connected strings s. For example, ["abc", 3] ="abcabcabc". On the other hand, we define that stri
阅读全文
摘要:In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach o
阅读全文
摘要:A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the
阅读全文
摘要:Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both
阅读全文
摘要:A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the
阅读全文
摘要:A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but i
阅读全文
摘要:Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
阅读全文
摘要: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
阅读全文
摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or
阅读全文
摘要:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum pro
阅读全文
摘要:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and r
阅读全文
摘要:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee
阅读全文
摘要:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2
阅读全文
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Note: Approach #1: My code. [C++] Appro
阅读全文
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Approach #1: DP. [C++] Ana
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文