Here are solutions (hopefully) to some of the problems on Leetcode, which is a collection of programming challenges.
- Array Partition I
-
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible.
-
- Invert Binary Tree
- Longest Substring Without Repeating Characters
-
Given a string, find the length of the longest substring without repeating characters.
CodeReview
discussion
-
- Maximum Depth of Binary Tree
- Single Number
-
Given an array of integers, every element appears twice except for one. Find that single one.
-
- Two Sum
-
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice.
-
- Linked List Addition
-
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself.
-
- Product of Array Except Self
-
Given an array of
n
integers wheren > 1
,nums
, return an array output such thatoutput[i]
is equal to the product of all the elements ofnums
exceptnums[i]
. -
Solve it without division and in
O(n)
. - For example, given
[1, 2, 3, 4]
return[24, 12, 8, 6]
.
-