Medium

/Tag:Medium
­

[Leetcode] Kth Largest Element in an Array

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

November 28th, 2015|Categories: DS and Algorithms, Sorting|Tags: , , , , , |

[Leetcode] Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.

November 14th, 2015|Categories: DS and Algorithms, Graph, Recursion, Tree|Tags: , , , , , |

[Leetcode] Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.

November 14th, 2015|Categories: DS and Algorithms, Graph, Tree|Tags: , , , , , , |

[Leetcode] Add Two Numbers

Add two linked lists representing two non-negative numbers.

November 14th, 2015|Categories: DS and Algorithms, Linked List|Tags: , , , |

[Leetcode] Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.

November 14th, 2015|Categories: DS and Algorithms, Hash|Tags: , , , |

[Leetcode] Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.

November 28th, 2015|Categories: DS and Algorithms, Linked List|Tags: , , , , |

[Leetcode] Sum Root to Leaf Numbers

Calculate the total sum of all root-to-leaf numbers.

November 14th, 2015|Categories: DS and Algorithms, Recursion, Tree|Tags: , , , , , |

[Leetcode] 3Sum

Given an array S of n integers, find there elements a, b, c in S such that a + b + c = 0.

November 14th, 2015|Categories: Array, DS and Algorithms|Tags: , , , , |

[Leetcode] 3Sum closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number.

November 14th, 2015|Categories: Array, DS and Algorithms|Tags: , , , , |

[Leetcode] Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

November 14th, 2015|Categories: Array, DS and Algorithms|Tags: , , , |

[Leetcode] Permutations

Given a collection of numbers, return all possible permutations.

November 14th, 2015|Categories: DS and Algorithms, Recursion|Tags: , , , , |

[Leetcode] Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.

November 14th, 2015|Categories: Array, DS and Algorithms|Tags: , , , |

[Leetcode] Spiral Matrix II

Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.

November 14th, 2015|Categories: Array, DS and Algorithms|Tags: , , , |

[Leetcode] Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.

November 14th, 2015|Categories: Array, DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Count Complete Tree Nodes

Given a complete binary tree, count the number of nodes.

November 14th, 2015|Categories: DS and Algorithms, Tree|Tags: , , , , , |

[Leetcode] Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.

November 14th, 2015|Categories: DS and Algorithms, Hash, Recursion|Tags: , , , |

[Leetcode] Reverse Linked List II

Reverse a linked list from position m to n. Do it in-place and in one-pass.

November 14th, 2015|Categories: DS and Algorithms, Linked List|Tags: , , , |

[Leetcode] Search for a Range

Given a sorted array of integers, find the starting and ending position of a given target value.

November 14th, 2015|Categories: DS and Algorithms, Searching|Tags: , , , , |

[Leetcode] Search Insert Position

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

November 14th, 2015|Categories: DS and Algorithms, Searching|Tags: , , , , |

[Leetcode] Subsets

Given a set of distinct integers, nums, return all possible subsets.

November 14th, 2015|Categories: Array, DS and Algorithms, Recursion|Tags: , , , , , |

[Leetcode] Subsets II

Given a collection of integers that might contain duplicates, nums, return all possible subsets.

November 14th, 2015|Categories: Array, DS and Algorithms, Recursion|Tags: , , , , , |

[Leetcode] Symmetric Tree

Given a binary tree, check whether it is a mirror of itself.

November 14th, 2015|Categories: DS and Algorithms, Recursion, Tree|Tags: , , , , |

[Leetcode] Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes' values. (Both recursive and iterative solutions)

November 14th, 2015|Categories: DS and Algorithms, Recursion, Stack|Tags: , , , , , , |

[Leetcode] Unique Paths

Help the robot to find all the unique paths from (0,0) to (m,n)

November 14th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Unique Paths II

Help the robot to find all the unique paths from (0,0) to (m,n) with obstacles

November 17th, 2015|Categories: DS and Algorithms, Dynamic Programming, Graph|Tags: , , , |

[Leetcode] Largest Number

Given a list of non negative integers, arrange them such that they form the largest number.

November 14th, 2015|Categories: DS and Algorithms, Sorting, String|Tags: , , , |

[Leetcode] Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.

November 14th, 2015|Categories: DS and Algorithms, Recursion|Tags: , , , , |

[Leetcode] Combination Sum II

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.

November 14th, 2015|Categories: DS and Algorithms, Recursion|Tags: , , , , |

[Leetcode] Combination Sum III

Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used.

November 29th, 2015|Categories: Array, DS and Algorithms, Recursion, Searching|Tags: , , , , |

[Leetcode] Lowest Common Ancestor of a Binary Tree

Given a binary tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.

November 14th, 2015|Categories: DS and Algorithms, Tree|Tags: , , , , |