Leetcode

/Tag:Leetcode
­

[Leetcode] Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.

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

[Leetcode] Contains Duplicate

Given an array of integers, find if the array contains any duplicates.

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

[Leetcode] Kth Smallest Element in a BST

Given a binary search tree, find the kth smallest element in it.

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

[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||

[Leetcode] Find Peak Element

Find a peak element in an array and return its index.

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

[Leetcode] Power of Two

Given an integer, write a function to determine if it is a power of two.

November 14th, 2015|Categories: Bit Manipulation, DS and Algorithms, Math||

[Leetcode] Rotate Array

Rotate an array of n elements to the right by k steps.

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

[Leetcode] Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.

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

[Leetcode] Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.

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

[Leetcode] Reverse Integer

Reverse digits of an integer. Return 0 when the reversed integer overflows.

November 14th, 2015|Categories: DS and Algorithms, Math||

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

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

[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||

Given two binary strings, return their sum (also a binary string).

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

[Leetcode] Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

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

[Leetcode] Contains Duplicate II

Find if a duplicate exists among the recent k numbers.

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

Given a linked list, determine if it has a cycle in it.

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

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||

[Leetcode] Plus One

Given a non-negative number represented as an array of digits, plus one to the number.

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

[Leetcode] Swap Nodes in Pairs

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

[Leetcode] Count and Say

Get the nth sequence of the count-and-say sequences.

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

[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||

[Leetcode] Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ‘ ‘, return the length of last word in the string.

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

[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||

[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||

[Leetcode] Remove Element

Given an array and a value, remove all instances of that value in place and return the new length.

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

[Leetcode] Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.

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

[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||

[Leetcode] Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

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

[Leetcode] Permutations

Given a collection of numbers, return all possible permutations.

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