原创 Leetcode Convert Sorted List to Binary Search Tree 把有序鏈表轉換成二叉搜索樹

題目: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 分析

原创 Leetcode Add Two Numbers 兩個鏈表表示的數相加

題目: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order an

原创 Leetcode Partition List 分割鏈表

題目: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than

原创 Leetcode Binary Tree Inorder Traversal 二叉樹中序遍歷

題目: Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,

原创 Leetcode Binary Tree Preorder Traversal 二叉樹先序遍歷

題目: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2

原创 Leetcode Copy List with Random Pointer 拷貝鏈表

題目: A linked list is given such that each node contains an additional random pointer which could point to any node

原创 Leetcode Reverse Nodes in k-Group

題目: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the numbe

原创 Leetcode Remove Nth Node From End of List 刪除鏈表倒數第n個元素

題目: Given a linked list, remove the nth node from the end of list and return its head. For example, Given linke

原创 Leetcode Sort List 鏈表排序

題目: Sort a linked list in O(n log n) time using constant space complexity. 分析: 選擇用歸併排序來解決。但是找中點的時候需要注意對於 1 --> 2 -

原创 Leetcode Swap Nodes in Pairs 交換鏈表的節點對

題目: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you sho

原创 Leetcode Binary Tree Level Order Traversal II 二叉樹分層遍歷

題目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right,

原创 Leetcode Rotate List 旋轉鏈表

  題目: Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->

原创 Leetcode Binary Tree Zigzag Level Order Traversal

題目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, the

原创 Leetcode Merge k Sorted Lists 合併k個鏈表

題目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 分析: 1. 用暴力的

原创 Leetcode Same Tree 判斷兩棵二叉樹是否相同

題目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered eq