随笔分类 -  Math

摘要:Given an m x n binary grid grid where each 1 marks the home of one friend, return the minimal total travel distance. The total travel distance is the 阅读全文
posted @ 2021-11-06 03:54 苗妙苗 阅读(48) 评论(0) 推荐(0) 编辑
摘要:Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers. Example 1: Input: n = 5 Output: 2 Explanati 阅读全文
posted @ 2021-08-31 09:29 苗妙苗 阅读(92) 评论(0) 推荐(0) 编辑
摘要:思路:就是把gcd拆一下,因为如果GCD可以,这些数就也可以3,6 gcd = n = 3 1/3 没了,0 += 2 GCD辗转相除法:b一开始是除数,后来是余数。余数为0就行了 16 4 4,4 4,0 所以返回a = 4 https://www.geeksforgeeks.org/common 阅读全文
posted @ 2020-10-26 10:19 苗妙苗 阅读(84) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空 阅读全文
posted @ 2018-09-05 04:56 苗妙苗 阅读(251) 评论(0) 推荐(0) 编辑
摘要:[抄题]: We have some permutation A of [0, 1, ..., N - 1], where N is the length of A. The number of (global) inversions is the number of i < j with 0 <= 阅读全文
posted @ 2018-08-28 04:19 苗妙苗 阅读(218) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Imagine you have a special keyboard with the following keys: Key 1: (A): Print one 'A' on screen. Key 2: (Ctrl-A): Select the whole screen. Key 阅读全文
posted @ 2018-08-24 06:26 苗妙苗 阅读(228) 评论(0) 推荐(0) 编辑
摘要:[抄题]: 简而言之:只能对 杯子中全部的水/容量-杯子中全部的水进行操作 You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. Yo 阅读全文
posted @ 2018-08-23 10:40 苗妙苗 阅读(271) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Given a number n. You ha 阅读全文
posted @ 2018-08-23 05:42 苗妙苗 阅读(128) 评论(0) 推荐(0) 编辑
摘要:[抄题]: A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bottom-left corner, and (x2, y2) are the coordi 阅读全文
posted @ 2018-08-10 21:56 苗妙苗 阅读(202) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not 阅读全文
posted @ 2018-08-06 23:25 苗妙苗 阅读(294) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we de 阅读全文
posted @ 2018-08-03 23:19 苗妙苗 阅读(184) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended f 阅读全文
posted @ 2018-07-26 09:42 苗妙苗 阅读(166) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Given a grid where each entry is only 0 or 1, find the number of corner rectangles. A corner rectangle is 4 distinct 1s on the grid that form an 阅读全文
posted @ 2018-05-19 22:05 苗妙苗 阅读(144) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 阅读全文
posted @ 2018-05-16 23:42 苗妙苗 阅读(103) 评论(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 阅读全文
posted @ 2018-05-08 10:52 苗妙苗 阅读(236) 评论(0) 推荐(0) 编辑
摘要:[抄题]: mplement pow(x, n), which calculates x raised to the power n (xn). Example 1: Example 2: Example 3: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出 阅读全文
posted @ 2018-05-05 22:35 苗妙苗 阅读(204) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Given an m * n matrix M initialized with all 0's and several update operations. Operations are represented by a 2D array, and each operation is 阅读全文
posted @ 2018-05-03 21:36 苗妙苗 阅读(145) 评论(0) 推荐(0) 编辑
摘要:[抄题]: We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, 阅读全文
posted @ 2018-05-03 17:06 苗妙苗 阅读(238) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Example 2: [暴力解法] 阅读全文
posted @ 2018-05-03 16:23 苗妙苗 阅读(378) 评论(0) 推荐(0) 编辑
摘要:[抄题]: Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is increment 阅读全文
posted @ 2018-05-03 10:31 苗妙苗 阅读(135) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示