![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
剑指Offer
Mr-aaaa
这个作者很懒,什么都没留下…
展开
-
调整数组顺序使奇数位于偶数前面
class Solution { int[] numss; public int[] exchange(int[] nums) { numss = nums; solution(0,nums.length - 1); return numss; } void solution(int l,int r){ if(l >= r) return; int i = l - 1 , j = r +.原创 2022-01-23 00:29:50 · 87 阅读 · 0 评论 -
剪绳子 Java
结论当整数中拆分成3和2时(2的数量不大于2个)积最大证明(参考y总):前提:假设结果为a1 - anai < 5反证法:若ai >=5,则ai = (ai - 3)*3 = 3ai - 9 > ai等价于 ai > 4.5ai > ai所以 ai <5ai 可以不为44 = 2 * 22的数量不大于22 + 2 + 2 = 62 * 2 * 2 = 8 < 3 * 3结论成立class Solution { public.原创 2022-01-18 23:32:32 · 207 阅读 · 0 评论 -
矩阵中的路径
dfs暴力class Solution { String w; char[][] b; public boolean exist(char[][] board, String word) { w = word; b = board; for(int i = 0;i < board.length; i++){ for(int j = 0;j < board[0].length; j++){ .原创 2022-01-14 22:07:58 · 235 阅读 · 0 评论 -
旋转数组的最小数字
整数二分class Solution { public int minArray(int[] numbers) { int l = 0; int r = numbers.length - 1; while(r > 0 && numbers[r] == numbers[l]) r--; if(numbers[r] >= numbers[l]) return numbers[l]; while.原创 2022-01-14 20:58:25 · 174 阅读 · 0 评论