![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
剑指offer
steins4
这个作者很懒,什么都没留下…
展开
-
面试题57和为s的数字面试题58
/** * @Author Administrator * @Author 2020/11/22 * 面试题57:和为s的数字 * 题目一:和为s的两个数字 * 输入一个递增排序的数组和一个数字s,在数组中查找两个字, * 使得它们的和正好是s,如果由多对数字的和等于s,则输出任意一组即可 */ public class FindNumsWithSum { /** *题目一:和为s的两个数字 *原创 2020-11-22 18:48:57 · 71 阅读 · 0 评论 -
面试题56:数组中数字出现的次数
/** * 面试题56:数组中数字出现的次数 */ public class FindNumsAppearOnce { /** * 题目1:数组中只出现一次的两个数字 * 一个整型数组中出两个数字之外,其他数字都出现了两次。 * 请写程序找出这两个只出现一次的数字,要求时间复杂度是O(n),空间复杂度是O(1) */ public static int[] findNumsAppearOnce(int[] nums,int le原创 2020-11-21 17:35:29 · 48 阅读 · 0 评论 -
面试题54,二叉搜索树的第k大节点;面试题53:在排序数组中查找数字
/** * 题目二:找到0~n-1中缺失的数字 * 一个长度为n-1的递增排序数组中的所有数字都是唯一的,并且每个数字 * 都在范围0~n-1中。在范围0~n-1内的n个数字中有且仅有一个数字不在该数组中,请找出这个数字. */ public class GetMissingNumber { public static int getMissingNumber(int[] array,int length){ if(array == null || len原创 2020-11-20 14:13:23 · 57 阅读 · 0 评论 -
面试题49,50,51,52
面试题49,50,51,52 /** * 面试题49:丑数 * 我们把只含有因子2,3,5的数成为丑数。求按从小到大的顺序的第1500个丑数。 * 例如,6,8都是丑数,但14不是,因为它包含因子7.习惯上我们把1当作第一个丑数 */ public class GetUglyNumber { /** *判断是否是丑数 */ public static boolean isUgly(int number){ while(numbe原创 2020-11-18 20:10:16 · 86 阅读 · 0 评论 -
面试题47:礼物的最大价值 面试题46
/** * @Author Administrator * @Author 2020/11/17 * 面试题47:礼物的最大价值 * */ public class MaxValueOfGift { public static int maxValueOfGift(int[][] values,int rows,int cols){ if(cols<=0 || rows <= 0 || values == null){ return原创 2020-11-17 12:25:58 · 80 阅读 · 0 评论 -
34,35
34,35 /** * 面试题34:二叉树中和为某一值的路径 * 输入一颗二叉树和一个整数,打印出二叉树中节点值的和为输入整数的所有路径。 * 从树的根节点开始往下一直到叶节点所经过的节点形成一条路径。 */ public class FindPath { public void findPath(BinaryTreeNode pRoot,int exceptedSum){ if(pRoot == null){ return ;原创 2020-11-09 20:27:16 · 54 阅读 · 0 评论