自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(39)
  • 收藏
  • 关注

原创 Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the

2015-02-24 17:00:24 231

原创 Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?//dp[i] = dp[i-1] + dp

2015-02-24 14:50:30 202

原创 Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2014-10-31 07:21:03 236

原创 Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node./** * Definition for binary tree

2014-08-01 11:02:25 239

原创 反转单链表

链表题

2014-07-30 23:55:23 228

原创 Insertion Sort List

Sort a linked list using insertion sort.用插入排序来排链表/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val

2014-07-23 17:54:10 214

原创 N-Queens II

Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.经典的八皇后问题这个比n皇后1简单 先做这个。规则是 行、列、正反对角线上都只能有一个皇后。1.常规做法。 递归

2014-07-22 17:42:47 220

原创 Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2014-07-20 10:06:34 293

原创 Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y

2014-07-20 10:01:29 180

原创 反转单链表

给定一个链表的头指针,要求遍历一次,将单链表中的顺序反过来。

2014-07-20 10:00:59 197

原创 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.1.递归

2014-07-20 09:58:27 212

原创 Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-

2014-07-20 09:55:41 279

原创 Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3删除链表中的重复点

2014-07-20 09:53:28 227

原创 Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?

2014-07-20 09:47:10 245

原创 Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?

2014-07-20 09:47:05 238

原创 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 / 3return [1,3,2].Note: Recursive solutio

2014-07-20 09:32:54 216

原创 Add Two Numbers

You are given two linked lists representing two non-negative numbers. 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 link

2014-07-20 09:32:50 249

原创 Best Time to Buy and Sell Stock III

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You may

2014-07-19 00:28:52 231

原创 Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2014-07-19 00:20:41 239

原创 Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on

2014-07-19 00:20:07 214

原创 Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2014-07-19 00:00:35 251

原创 Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100"1.sum的数组长度不可以定义,否则没有进位的数最前面会有一个空格2.Char和string的转换3.进位表示法

2014-07-18 23:57:52 239

原创 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly

2014-07-18 23:53:11 218

原创 4Sum

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Element

2014-07-18 23:53:02 207

原创 3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:· Elements in a triplet (a,b,c) must

2014-07-18 23:48:17 209

原创 Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before coding.

2014-07-18 23:42:46 221

原创 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 farthest leaf node.

2014-07-18 23:36:52 311

原创 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 identical and the nodes have the same value.

2014-07-18 23:36:46 208

原创 Single Number

Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra

2014-07-18 23:31:39 277

原创 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.If the last word does not exist, return 0.Note: A word is

2014-07-18 23:28:06 214

原创 Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?爬n层楼梯 每次能走1huo

2014-07-18 20:31:45 238

原创 Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.罗马数字转整数 = =

2014-07-17 23:18:43 213

原创 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.You may assume no duplicates in the array.

2014-07-17 23:07:38 217

原创 Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va

2014-07-17 17:16:19 205

原创 Pow(x, n)

Implement pow(x, n).最先想到的就是d

2014-07-17 11:19:36 247

转载 位运算

先来复习下。。

2014-07-16 18:34:00 199

原创 Copy List with Random Pointer

Copy List with Random Pointer Total Accepted: 14031 Total Submissions: 61754My SubmissionsA linked list is given such that each node contains an additional random pointer which could poi

2014-07-15 17:55:07 516

原创 Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2014-07-14 22:34:48 227

原创 Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You m

2014-07-14 21:53:02 306

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

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