摘要:
Problem Description:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null... 阅读全文
摘要:
Problem Description:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more diction... 阅读全文
摘要:
Problem Description:Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Ret... 阅读全文
摘要:
Problem Description:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Solution: 1 public bo... 阅读全文
摘要:
Problem Description:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without u... 阅读全文
摘要:
Problem Description:Given a singly linked listL: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 no... 阅读全文
摘要:
Problem Description:Given a binary tree, return thepreordertraversal of its nodes' values.Solution: 1 public List preorderTraversal(TreeNode root)... 阅读全文
摘要:
Problem Description:Given a binary tree, return thepostordertraversal of its nodes' valuesSolution: 1 public List postorderTraversal(TreeNode root) { ... 阅读全文
摘要:
Problem Description:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.ge... 阅读全文
摘要:
Problem Description:Sort a linked list using insertion sort.Solution: 1 public class Solution { 2 public ListNode insertionSortList(ListNode head)... 阅读全文