Find Minimum in Rotated Sorted Array

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). Find the minimum elem...

2015-07-31 22:42:12

阅读数:142

评论数:0

Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. /** * Definition for a binary tree node. * publi...

2015-07-31 11:04:19

阅读数:104

评论数:0

Integer to Roman

Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. public class Solution { public ...

2015-07-31 00:05:53

阅读数:107

评论数:0

roman to integer

Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. public class Solution { public ...

2015-07-30 23:13:50

阅读数:138

评论数:0

Implement Queue using Stacks

Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue.pop() -- Removes the element from in fr...

2015-07-30 22:19:03

阅读数:105

评论数:0

Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−...

2015-07-30 20:49:16

阅读数:91

评论数:0

Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 uniqu...

2015-07-29 21:09:23

阅读数:172

评论数:0

Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums...

2015-07-28 22:29:02

阅读数:142

评论数:0

Majority Element

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume th...

2015-07-28 22:02:37

阅读数:103

评论数:0

Contains Duplicate

Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the ...

2015-07-28 20:57:57

阅读数:105

评论数:0

Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate ...

2015-07-28 20:20:06

阅读数:129

评论数:0

Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 /** * Definition for ...

2015-07-28 19:13:14

阅读数:116

评论数:0

Maximum Depth of Binary Tree

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

2015-07-28 17:52:27

阅读数:151

评论数:0

Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2...

2015-07-28 17:52:02

阅读数:96

评论数:0

Single Number

Given an array of integers, every element appears twice except for one. Find that single one. public class Solution { public int singleN...

2015-07-28 17:48:29

阅读数:112

评论数:0

Same Tree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identic...

2015-07-28 17:46:20

阅读数:107

评论数:0

Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3...

2015-07-28 17:45:36

阅读数:135

评论数:0

Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / ...

2015-07-28 17:45:10

阅读数:105

评论数:0

Excel Sheet Column Number

Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For exam...

2015-07-28 17:41:00

阅读数:75

评论数:0

Number of 1 Bits

Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 3...

2015-07-28 17:40:09

阅读数:107

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭