Pow(x, n) 能够直接用库函数pow(x,n)一步搞定,但明显这样就没意思了。 參考 快 速 幂 取 模 二分。复杂度为O(logn) 递归方法 class Solution { public: double myPow(double x, int n) { if(n<0) return 1.
转载
2017-04-23 18:05:00
50阅读
leetcoder 403. Frog Jump 题解https://leetcode.com/problems/frog-jump/题目描述在一条河(直线)上有一些石子,我们只能在石子
原创
2022-08-30 10:52:40
127阅读
题目链接 \(O(n^2)\) 做法 用 \(f[i]\) 表示前 \(i\) 位中以第 \(i\) 位作为结尾的 LIS 长度。 转移的方程显然 \(f[j]=\max\{f[i]+1,f[j]\} (i<j,a[i]<a[j])\) class Solution { public: int le ...
转载
2021-09-08 19:19:00
230阅读
2评论
坚持写博客是一个好习惯,日日精进。20210831每日一题(get到差分法)1109. 航班预订统计1.暴力解法(面试官可能会挂人) leetcoder 在评论区评论 这道题面试官给他30分钟,他3分钟写出暴力解法,直接被挂掉。class Solution { public int[] corpFlightBookings(int[][] bookings, int n) { int len = bookings.length; int[] dp .
原创
2022-01-13 13:52:59
476阅读