11 2019 档案

摘要:剑指 Offer 09. 用两个栈实现队列 用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead ,分别完成在队列尾部插入整数和在队列头部删除整数的功能。(若队列中没有元素,deleteHead 操作返回 -1 ) class CQueue { S 阅读全文 »
posted @ 2019-11-21 22:08 无名客nameless 阅读(56) 评论(0) 推荐(0) 编辑
摘要:剑指 Offer 06. 从尾到头打印链表 class Solution { public int[] reversePrint(ListNode head) { Stack<Integer> stack = new Stack<>(); while(head != null){ stack.pus 阅读全文 »
posted @ 2019-11-20 12:08 无名客nameless 阅读(53) 评论(0) 推荐(0) 编辑
摘要:剑指 Offer 05. 替换空格 class Solution { public String replaceSpace(String s) { StringBuilder str = new StringBuilder(s); int p1 = str.length() - 1; for(int 阅读全文 »
posted @ 2019-11-20 11:18 无名客nameless 阅读(49) 评论(0) 推荐(0) 编辑
摘要:剑指 Offer 03. 数组中重复的数字 哈希表/set class Solution { public int findRepeatNumber(int[] nums) { HashSet<Integer> set = new HashSet<>(); for(int num : nums){ 阅读全文 »
posted @ 2019-11-20 10:59 无名客nameless 阅读(50) 评论(0) 推荐(0) 编辑
摘要:lc88 class Solution { public void merge(int[] nums1, int m, int[] nums2, int n) { int i = m - 1, j = n - 1; int p = m + n - 1; while(i >= 0 && j >= 0) 阅读全文 »
posted @ 2019-11-20 10:02 无名客nameless 阅读(61) 评论(0) 推荐(0) 编辑
摘要:int和Integer的区别 1、Integer是int的包装类,int则是java的一种基本数据类型 2、Integer变量必须实例化后才能使用,而int变量不需要 3、Integer实际是对象的引用,当new一个Integer时,实际上是生成一个指针指向此对象;而int则是直接存储数据值 4、I 阅读全文 »
posted @ 2019-11-16 17:06 无名客nameless 阅读(108) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示