Clarification:: In-Place In-Place
Clarification:: In-Place In-Place
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra
memory.
Clarification:
Confused why the returned value is an integer but your answer is an array?
Note that the input array is passed in by reference, which means a modification to the input array will be known to the
caller as well.
Example 1:
Example 2:
Constraints:
********************
53. Maximum Subarray
********************
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and
return its sum.
Example 1:
Example 2:
Example 3:
Constraints:
Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach,
which is more subtle.
*******************
70. Climbing Stairs
*******************
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Example 1:
Input: n = 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
Example 2:
Input: n = 3
Output: 3
Explanation: There are three ways to climb to the top.
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step
Constraints:
1 <= n <= 45
**************************************
83. Remove Duplicates from Sorted List
**************************************
Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list
sorted as well.
Example 1:
Example 2:
Constraints:
*********************************
104. Maximum Depth of Binary Tree
*********************************
A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf
node.
Example 1:
Example 2:
Example 3:
Input: root = []
Output: 0
Example 4:
Constraints:
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
Example 1:
Example 2:
Constraints:
*************
112. Path Sum
*************
Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up
all the values along the path equals targetSum.
A leaf is a node with no children.
Example 1:
Example 2:
Example 3:
Constraints: