![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
Focus_Liu
做最骚的程序员,最吊的Team Leader。 欢迎加入java、算法、大模型技术群:329019348
展开
-
合并两个有序链表
非递归: /** * 用一个遍历来装排好序的链表,和一个遍历记录最其实的位置。 * @param l1 * @param l2 * @return */ public static ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode resul...原创 2020-01-16 23:24:07 · 85 阅读 · 0 评论 -
栈排序-O(1)空间复杂度(猎聘网)
有两个栈a和b。栈a中数据是无序,栈b无数据。现在需要把a中的数据移动到b,并且最后b是有序的(栈顶最小)。要求:空间复杂度为O(1). private static void fun(Stack<Integer> a, Stack<Integer> b) { while (!a.isEmpty()){ Integer one = a.pop()...原创 2019-04-03 13:54:55 · 576 阅读 · 0 评论