LeetCode in Swift: Binary Tree Level Order Traversal II

Problem Statement 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). For example: Given binary tree {3,9,20,#,#,15,7},

return its bottom-up level order traversal as:

Original LeetCode problem page My Solution in Swift Continue reading...

LeetCode in Swift: Binary Tree Level Order Traversal

Problem Statement Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7},

return its level order traversal as:

Original LeetCode problem page My Solution in Swift Continue reading...

LeetCode in Swift: Insertion Sort List

Problem Statement Sort a linked list using insertion sort. Original LeetCode problem page My Solution in Swift Every time after inserting a list node, I use a variable to record the reference to that node. When next uninserted list node comes in, it checks from the recorded last inserted node instead of restarting the checking from the head list node. Continue reading...

LeetCode in Swift: Sort List

Problem Statement Sort a linked list in O(n log n) time using constant space complexity. Original LeetCode problem page My Solution in Swift I used a bottom-up iterative merge-sort to solve this problem with O(n log n) time efficiency and O(1) space efficiency. Note that, you cannot use traditional recursive merge-sort to tackle this problem; Continue reading...

LeetCode in Swift: Evaluate Reverse Polish Notation

Problem Statement Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples:

Original LeetCode problem page My Solution in Swift Continue reading...