摘要:
The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, forn= 3):"123""132""213""231""312""321"Givennandk, return thekthpermutation sequence.Not 阅读全文
posted @ 2013-09-10 02:00
LEDYC
阅读(99)
评论(0)
推荐(0)
摘要:
Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.---/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = 阅读全文
posted @ 2013-09-10 01:41
LEDYC
阅读(131)
评论(0)
推荐(0)
摘要:
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as1and0respectively in the grid.For example,There is one obstacle in the middle of a 3x3 grid as illustrated below.[ [0,0,0], [0,1, 阅读全文
posted @ 2013-09-10 01:36
LEDYC
阅读(127)
评论(0)
推荐(0)
摘要:
A robot is located at the top-left corner of amxngrid (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 bottom-right corner of the grid (marked 'Finish' in the diagram below).How many possible uni 阅读全文
posted @ 2013-09-10 00:50
LEDYC
阅读(147)
评论(0)
推荐(0)
摘要:
Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move either down or right at any point in time.---DP !!!---1. basic 二维数组注意i=0, j=0,其他min[i][j] = Math.min(min[i][j-1], min[i-1][j]) + grid[ 阅读全文
posted @ 2013-09-10 00:25
LEDYC
阅读(176)
评论(0)
推荐(0)
摘要:
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.---/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * ... 阅读全文
posted @ 2013-09-10 00:11
LEDYC
阅读(74)
评论(0)
推荐(0)
摘要:
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".---public class Solution { public String addBinary(String a, String b) { // convert to int if(a == null || b == null) return null; int x = 0; for(int i=... 阅读全文
posted @ 2013-09-10 00:01
LEDYC
阅读(95)
评论(0)
推荐(0)
浙公网安备 33010602011771号