剑指offer刷题(Java实现)
文章平均质量分 60
收藏面试常考的剑指offer中的题目的巧妙解法
青冥夜雨寒风吹
这个作者很懒,什么都没留下…
展开
-
剑指offer中关于或暗含数组 / 矩阵的题目的整理(待更)
<数组中数字(字符)出现的次数>类题目:网址:待更新机器人的运动范围(medium难度)https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/本题思路来源:作者:jyd链接:https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-ii-lcof/solution/mian-shi-ti-56-ii-shu-zu-zho原创 2021-02-04 11:13:12 · 84 阅读 · 1 评论 -
剑指offer中使用哈希表的题目的整理(待更)
最长不含重复字符的子字符串(medium难度)https://leetcode-cn.com/problems/zui-chang-bu-han-zhong-fu-zi-fu-de-zi-zi-fu-chuan-lcof/与本题相同题目:LeetCode3.无重复字符的最长子串以下方法思路及代码的来源:作者:jyd链接:https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/solution/mian-shi-ti-10-原创 2021-01-31 14:39:56 · 89 阅读 · 0 评论 -
剑指offer中使用滑动窗口的题目的整理(待更)
最长不含重复字符的子字符串(medium难度)https://leetcode-cn.com/problems/zui-chang-bu-han-zhong-fu-zi-fu-de-zi-zi-fu-chuan-lcof/与本题相同题目:LeetCode3.无重复字符的最长子串本方法思路和代码来源:作者:guanpengchn链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characte原创 2021-01-31 14:39:38 · 104 阅读 · 0 评论 -
剑指offer中关于有限状态自动机的题目的整理(待更)
表示数值的字符串(medium难度)https://leetcode-cn.com/problems/biao-shi-shu-zhi-de-zi-fu-chuan-lcof/class Solution { public boolean isNumber(String s) { Map[] states = { new HashMap<>() {{ put(' ', 0); put('s', 1)原创 2021-01-27 18:17:45 · 256 阅读 · 0 评论 -
剑指offer中关于二叉树的题目的整理(待更)
对称二叉树(simple难度)https://leetcode-cn.com/problems/dui-cheng-de-er-cha-shu-lcof/与本题相同题目:LeetCode101.对称二叉树本文思路及解法来源:作者:jyd链接:https://leetcode-cn.com/problems/dui-cheng-de-er-cha-shu-lcof/solution/mian-shi-ti-28-dui-cheng-de-er-cha-shu-di-gui-qing/原创 2021-01-27 18:16:51 · 188 阅读 · 0 评论 -
剑指offer中链表类题目的整理(待更)
1 二叉搜索树与双向链表(medium难度)https://leetcode-cn.com/problems/er-cha-sou-suo-shu-yu-shuang-xiang-lian-biao-lcof/原创 2021-01-24 19:15:39 · 84 阅读 · 0 评论 -
剑指offer中使用辅助栈方法的题目的整理(待更)
栈的压入、弹出序列(medium难度)https://leetcode-cn.com/problems/zhan-de-ya-ru-dan-chu-xu-lie-lcof/本题思路及代码的来源:作者:jyd链接:https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/solution/mian-shi-ti-10-i-fei-bo-na-qi-shu-lie-dong-tai-gui/来源:力扣(LeetCode)原创 2021-01-17 15:30:27 · 91 阅读 · 0 评论 -
剑指offer中涉及到大数越界的题目的整理(待更)
剪绳子Ⅱ(medium难度)https://leetcode-cn.com/problems/jian-sheng-zi-ii-lcof/本题思路及代码的来源:作者:jyd链接:https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/solution/mian-shi-ti-10-i-fei-bo-na-qi-shu-lie-dong-tai-gui/来源:力扣(LeetCode)注:剪绳子Ⅰ(medium难度)传送门原创 2021-01-13 20:26:51 · 220 阅读 · 1 评论 -
剑指offer中关于数学推导的题目的整理(待更)
剪绳子Ⅰ(medium难度)https://leetcode-cn.com/problems/jian-sheng-zi-lcof/本题思路及代码的来源:作者:jyd链接:https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/solution/mian-shi-ti-10-i-fei-bo-na-qi-shu-lie-dong-tai-gui/来源:力扣(LeetCode)class Solution原创 2021-01-13 20:25:07 · 70 阅读 · 0 评论 -
剑指offer中解法奇妙的题目(待更)
本文解题思路和代码来源:作者:jyd链接:https://leetcode-cn.com/problems/er-cha-shu-de-zui-jin-gong-gong-zu-xian-lcof/solution/mian-shi-ti-68-ii-er-cha-shu-de-zui-jin-gong-gon-7/来源:力扣(LeetCode)1 求1+2+...+n(medium难度)https://leetcode-cn.com/problems/qiu-12n-lcof/原创 2020-12-24 10:31:26 · 65 阅读 · 2 评论 -
剑指offer中关于位运算的题目的整理(待更)
本文解题思路和代码来源:作者:jyd链接:https://leetcode-cn.com/problems/er-cha-shu-de-zui-jin-gong-gong-zu-xian-lcof/solution/mian-shi-ti-68-ii-er-cha-shu-de-zui-jin-gong-gon-7/来源:力扣(LeetCode)1 二进制中1的个数https://leetcode-cn.com/problems/er-jin-zhi-zhong-1de-ge-shu-lco原创 2020-12-21 18:14:15 · 85 阅读 · 0 评论 -
二叉树和二叉搜索树的最近公共祖先解法
1 二叉树的最近公共祖先//情况1合并至情况3,4的写法class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if(root == null || root == p || root == q) return root;//如果树为空,直接返回null,或者如果p和q中有等于root的,那么它们的最近公共祖先即为原创 2020-12-21 11:51:01 · 529 阅读 · 2 评论 -
剑指 Offer 40. 最小的k个数(经典的TopK问题)
1 类似快速排序的快速选择法(分治法思想)“查找第 k 大的元素”是一类算法问题,称为选择问题。找第 k 大的数,或者找前 k 大的数,有一个经典的 quick select(快速选择)算法。这个名字和 quick sort(快速排序)看起来很像,算法的思想也和快速排序类似,都是分治法的思想。首先回顾快速排序的思路。快速排序中有一步很重要的操作是 partition(划分),从数组中随机选取一个枢纽元素 v,然后原地移动数组中的元素,使得比 v 小的元素在 v 的左边,比 v 大的元素在 v 的右边原创 2020-12-16 13:14:24 · 224 阅读 · 0 评论