摘要:
Sort a linked list using insertion sort. 插入排序。 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNo 阅读全文
摘要:
esign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the 阅读全文
摘要:
Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. Note: Recursive sol 阅读全文
摘要:
Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,2,3]. Note: Recursive solu 阅读全文
摘要:
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' values. For 阅读全文
摘要:
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up:Can you 阅读全文
摘要:
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 判断是否成环 1、利用set,很简单,但是题目中说不要用额外的空间。 2、设置两 阅读全文
摘要:
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such p 阅读全文
摘要:
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For 阅读全文
摘要:
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. Return a deep copy 阅读全文