随笔分类 - Math
摘要:Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4. However, you can add any
阅读全文
摘要:Given an array of integers A, consider all non-empty subsequences of A. For any sequence S, let the width of S be the difference between the maximum a
阅读全文
摘要:Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays where the product of all the elements in the s
阅读全文
摘要:Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.
阅读全文
摘要:Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requ
阅读全文
摘要:Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be
阅读全文
摘要:Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Note: The len
阅读全文
摘要:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twi
阅读全文
摘要:Given a string S, count the number of distinct, non-empty subsequences of S . Since the result may be large, return the answer modulo 10^9 + 7. Exampl
阅读全文
摘要:You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty. For each move, you could choose any m (1 ≤
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Input: 2 Output: 91 Explanation: The answer shoul
阅读全文
摘要:Bholu the Pandit on this New Year wanted to divide his Cuboidal Packaging block into cubes. But he loves uniformity so he asks you to divide it such a
阅读全文
摘要:Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes
阅读全文
摘要:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Input: n = 10 Outpu
阅读全文
摘要:We are given non-negative integers nums[i] which are written on a chalkboard. Alice and Bob take turns erasing exactly one number from the chalkboard,
阅读全文