math
Nahida_nora
这个作者很懒,什么都没留下…
展开
-
Lintcode 197 排列序号
Lintcode 197 排列序号Math:举例:1, 2, 3, 4第一位是1,没有比1小的,所以 0,第二位是2, 后面没有比2小的,所以0…结果 0 + 1 =1举例:4, 3, 2, 1第一位是4,(1,2,3) 小于4,所以 3 * 3!,第二位是2, (2, 1)小于3,2 * 2!第三位是2,(1)小于2, 1 * 1!…结果 3 * 3! + 2 * 2!+ 1 * 1!+ 1 =24当前的index = 它之前所有字典序的排列的数之和 + 1举例:4, 2原创 2020-07-09 04:13:10 · 106 阅读 · 0 评论 -
Lintcode 254 Drop Eggs
Lintcode 254 Drop EggsMath:假设上限变成了(x-1)次,要是鸡蛋一直坚挺不碎的话,那么接下来就是(x-2),(x-3) …x + (x-1) + (x-2) + … + 1 = 100x =14第一个鸡蛋碎之前扔的楼层应该是14,27,39,50,60,69, 77, 84, 90, 95, 99, 100最多是在14的时候,鸡蛋碎了,第二个鸡蛋需要14次(最多)-1(最少)。public int dropEggs(int n) { long ans = 0原创 2020-07-08 22:48:44 · 76 阅读 · 0 评论 -
Leetcode 1124. Longest Well-Performing Interval
Leetcode 1124. Longest Well-Performing IntervalWe starts with a score = 0,If the working hour > 8, we plus 1 point.Otherwise we minus 1 point.We want find the maximum interval that have strict positive score.After one day of work, if we find the to原创 2020-06-08 08:23:31 · 151 阅读 · 0 评论