随笔分类 -  algorithms

1 2 3 4 5 ··· 7 下一页
摘要:Source Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes. The lowest common ancestor is the node wi 阅读全文
posted @ 2024-05-12 16:47 凌雨尘 阅读(22) 评论(0) 推荐(0)
摘要:Source Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example Given the below binary tree, 1 / \ 阅读全文
posted @ 2024-03-09 15:20 凌雨尘 阅读(42) 评论(0) 推荐(0)
摘要:Source Problem Statement Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a bina 阅读全文
posted @ 2024-02-03 13:05 凌雨尘 阅读(27) 评论(0) 推荐(0)
摘要:Source Problem Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the rootnode down to 阅读全文
posted @ 2024-01-07 21:05 凌雨尘 阅读(50) 评论(0) 推荐(0)
摘要:Source Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root 阅读全文
posted @ 2023-12-20 20:51 凌雨尘 阅读(23) 评论(0) 推荐(0)
摘要:Source Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). Example Given binary tree 阅读全文
posted @ 2023-11-04 21:30 凌雨尘 阅读(26) 评论(0) 推荐(0)
摘要:Source Given a binary tree, return the postorder traversal of its nodes' values. Example Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Challe 阅读全文
posted @ 2023-10-14 15:35 凌雨尘 阅读(24) 评论(0) 推荐(0)
摘要:Source Given a binary tree, return the inorder traversal of its nodes' values. Example Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Challeng 阅读全文
posted @ 2023-09-02 14:29 凌雨尘 阅读(21) 评论(0) 推荐(0)
摘要:Source Given a binary tree, return the preorder traversal of its nodes' values. Note Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Example Ch 阅读全文
posted @ 2023-08-12 22:28 凌雨尘 阅读(37) 评论(0) 推荐(0)
摘要:Source Problem Remove all elements from a linked list of integers that have value val. Example Given 1->2->3->3->4->5->3, val = 3, you should return t 阅读全文
posted @ 2023-07-22 14:07 凌雨尘 阅读(17) 评论(0) 推荐(0)
摘要:Source Problem Given a linked list, swap every two adjacent nodes and return its head. Example Given 1->2->3->4, you should return the list as 2->1->4 阅读全文
posted @ 2023-06-11 13:40 凌雨尘 阅读(29) 评论(0) 推荐(0)
摘要:Source Problem Given a list, rotate the list to the right by k places, where k is non-negative. Example Given 1->2->3->4->5 and k = 2, return 4->5->1- 阅读全文
posted @ 2023-05-02 14:17 凌雨尘 阅读(24) 评论(0) 推荐(0)
摘要:Problem Statement Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. 阅读全文
posted @ 2023-04-02 14:24 凌雨尘 阅读(30) 评论(0) 推荐(0)
摘要:Source Implement an algorithm to delete a nodein the middle of a singly linked list, given only access to that node. Example Given 1->2->3->4, and nod 阅读全文
posted @ 2023-03-05 12:15 凌雨尘 阅读(48) 评论(0) 推荐(0)
摘要:Source Given a singly linked list of characters, write a function that returns true if the given list is palindrome, else false. 题解1 - 使用辅助栈 根据栈的特性(FI 阅读全文
posted @ 2023-02-12 11:56 凌雨尘 阅读(55) 评论(0) 推荐(0)
摘要:Source Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the fir 阅读全文
posted @ 2022-12-04 14:29 凌雨尘 阅读(52) 评论(0) 推荐(0)
摘要:Source Sort a linked list in O(n log n) time using constant space complexity. 题解1 - 归并排序(链表长度求中间节点) 链表的排序操作,对于常用的排序算法,能达到 O(nlogn) 的复杂度有快速排序(平均情况)、归并排 阅读全文
posted @ 2022-11-12 22:24 凌雨尘 阅读(75) 评论(0) 推荐(0)
摘要:Source A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or nul 阅读全文
posted @ 2022-10-16 11:51 凌雨尘 阅读(46) 评论(0) 推荐(0)
摘要:Source Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' val 阅读全文
posted @ 2022-09-11 22:01 凌雨尘 阅读(58) 评论(0) 推荐(0)
摘要:Source You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linke 阅读全文
posted @ 2022-08-13 22:39 凌雨尘 阅读(112) 评论(0) 推荐(0)

1 2 3 4 5 ··· 7 下一页