倮聊qq群,恐龙战队美版,丹东房屋供求信息
remove all elements from a linked list of integers that have value val. example given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6 return: 1 --> 2 --> 3 --> 4 --> 5
/** * definition for singly-linked list. * public class listnode { * int val; * listnode next; * listnode(int x) { val = x; } * } */ public class solution { public listnode removeelements(listnode head, int val) { if(head == null){ return null; } while(head.val == val){ head = head.next; if(head == null){ return null; } } listnode prev = head; while(prev.next != null){ while(prev.next.val == val){ prev.next = prev.next.next; if(prev.next == null){ return head; } } prev = prev.next; } return head; } }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论