1.2k words 1 mins.

67 · Binary Tree Inorder Traversal - LintCode # Description Given a binary tree, return the inorder traversal of its nodes‘ values. # Example Example 1: Input: binary tree = {1,2,3} Output: [2,1,3] # Solution 先把左邊的孩子全都放到 stack 裡 peek(): if node.right == null,先 pop 掉 看一下現在的...
1.7k words 2 mins.

69 · Binary Tree Level Order Traversal - LintCode # Description Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).) # Example Example 1: Input: tree = {1,2,3} Output: [[1],[2,3]] Explanation: 1 / \ 2 3 it...
1.3k words 1 mins.

[384 · Longest Substring Without Repeating Characters - LintCode](https://www.lintcode.com/problem/384/ # Description Given a string, find the length of the longest substring without repeating characters. # Example Example 1: Input: "abcabcbb" Output: 3 Explanation: The longest...
962 words 1 mins.

469 · Same Tree - LintCode # Description Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has the same value. # Example Example...
1.6k words 1 mins.

221 · Add Two Numbers II - LintCode # Description You have two numbers represented by linked list, where each node contains a single digit. The digits are stored in forward order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum...
854 words 1 mins.

101 · Remove Duplicates from Sorted Array II - LintCode 和 Lintcode 100 - Remove Duplicates from Sorted Array 相像的題 # Description Given a sorted array, remove the duplicates in place such that each element appear at most twice and return the new length. If a number appears more than two times, then...
814 words 1 mins.

easy: 100 · Remove Duplicates from Sorted Array - LintCode # Description Given a sorted array, 'remove' the duplicates in place such that each element appear only once and return the 'new' length. Do not allocate extra space for another array, you must do this in place with constant...
2.7k words 2 mins.

200 · Longest Palindromic Substring - LintCode # Description Given a string S , find the longest palindromic substring in S . You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.) # Example Example...
704 words 1 mins.

646 · First Position Unique Character - LintCode # Description Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1 . # Example Example 1: Input : s = "lintcode" Output : 0 Example 2: Input : s =...
2.6k words 2 mins.

788 · The Maze II - LintCode # Description There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up , down , left or right , but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. Given the...