![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法面试题
知道越多,知道越少
正在学习java开发,努力中
展开
-
单链表面试题(百度)-1级难度
逆序打印单链表? 思路如下: 话不多说,开始实操~ public static void reversePrint(HeroNode head){ if (head.next==null){ return ; } Stack<HeroNode> stack = new Stack<>(); HeroNode cur= head.next; while (cur!=null){原创 2021-01-09 10:09:22 · 59 阅读 · 0 评论 -
单链表面试题(腾讯)-2级难度
单链表的反转? 思路: public static void reverseList(HeroNode head){ if (head.next==null||head.next.next==null){ return ; } HeroNode cur =head.next; HeroNode next=null; HeroNode reverseHead=new HeroNode(0,"","");原创 2021-01-08 15:10:34 · 66 阅读 · 0 评论 -
单链表面试题(新浪)-1级难度
查找单链表倒数第K个结点? 方法如下: public static HeroNode findLastIndexNode(HeroNode head,int lastindex){ if(head.next==null){ return null; } int size = getListLength(head); HeroNode cur=head.next; if (lastindex<原创 2021-01-08 13:54:18 · 88 阅读 · 1 评论 -
单链表面试题-1级难度
求单链表中有效节点的个数? 这里是代码: public static int getListLength(HeroNode head){ if(head.next==null){ return 0; } int length=0; HeroNode cur=head.next; while (cur!=null){ length++; cur=cur原创 2021-01-08 09:53:41 · 60 阅读 · 0 评论