LeetCode-Python: Maxinum Depht of Binary Tree

Problem: Given a binary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

Read More

LeetCode-Python: Single Number

Problem: Given an array of integers, every element appears twice except for one. Find that single one.

Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

Read More

LeetCode-Python: Search in Rotated Sorted Array II

Problem: Follow up for “Search in Rotated Sorted Array”:
What if duplicates are allowed?

Would this affect the run-time complexity? How and why?

Read More

LeetCode-Python: Search in Rotated Sorted Array

Problem: Suppose a sorted array is rotated at some pivot unknown to you beforehand.

(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).

Read More

LeetCode-Python: Remove Duplicates from Sorted Array II

Problem: Follow up for “Remove Duplicates”:
What if duplicates are allowed at most twice?

For example,
Given sorted array A = [1,1,1,2,2,3],

Read More

LeetCode-Python: Remove Duplicates from Sorted Array

Problem: 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 memory.

Read More