自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 资源 (2)
  • 收藏
  • 关注

翻译 Shortest Palindrome

问题描述Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.For examp

2015-05-26 14:09:09 667

原创 House Robber II

问题描述After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a

2015-05-25 11:21:57 427

原创 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 and each combination should be a unique set of numbers.Ensure that numbers wit

2015-05-25 10:55:09 745

原创 Word Break

问题描述Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given s = “leetcode”, dict = [“leet”,

2015-05-17 11:22:29 364

翻译 Isomorphic Strings

问题描述Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another c

2015-04-30 10:34:58 318

原创 Generate Parentheses

问题描述Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:“((()))”, “(()())”, “(())()”, “()(())”, “()()()”思考

2015-04-30 10:26:27 335

原创 Merge k Sorted Lists

问题描述Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思考:k路归并,用什么?排序想法1、利用最小堆。堆顶是最小元素,取出后调整堆。如果元素取出后链表为null,则将堆末尾的list放到堆顶。堆长度减一,并调整堆。2、其实其他排序也可以。这里复习了

2015-04-24 11:22:44 340

原创 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 ma

2015-04-24 09:50:26 302

原创 Implement strStr

问题描述Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.思考:字符串匹配,KMP算法想法1、暴力匹配苏纳法效率肯定不高2、重温一下KMP算法,next数组3、学习一下BM算法和sunday算法(一

2015-04-22 11:26:16 365

原创 Substring with Concatenation of All Words

问题描述You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and

2015-04-21 10:44:12 306

原创 Next Permutation

问题描述Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible

2015-04-20 12:15:55 408

原创 基站选址

问题描述描述 需要在一个N × M的网格中建立一个通讯基站,通讯基站仅必须建立在格点上。网格中有A个用户,每个用户的通讯代价是用户到基站欧几里得距离的平方。网格中还有B个通讯公司,维护基站的代价是基站到最近的一个通讯公司的路程(路程定义为曼哈顿距离)。在网格中建立基站的总代价是用户通讯代价的总和加上维护基站的代价,最小总代价。输入 第一行为一个整数T,表示数据组数。每组数据第一行为四个整数:N,

2015-04-19 20:35:44 1261

原创 2月29日

问题描述描述 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期)。只有闰年有2月29日,满足以下一个条件的年份为闰年:年份能被4整除但不能被100整除年份能被400整除输入 第一行为一个整数T,表示数据组数。之后每组数据包含两行。每一行格式为”month day, year”,表示一个日期。month为{“January”, “February”, “March”, “Ap

2015-04-19 19:14:42 632

原创 回文字符序列

题目描述描述 给定字符串,求它的回文子序列个数。回文子序列反转字符顺序后仍然与原序列相同。例如字符串aba中,回文子序列为”a”, “a”, “aa”, “b”, “aba”,共5个。内容相同位置不同的子序列算不同的子序列。输入 第一行一个整数T,表示数据组数。之后是T组数据,每组数据为一行字符串。输出 对于每组数据输出一行,格式为”Case #X: Y”,X代表数据编号(从1开始),Y为答案

2015-04-19 19:07:12 605

原创 Longest Valid Parentheses

问题描述Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()(()”, the longest valid parentheses substring is “()”, wh

2015-04-19 13:32:55 322

原创 Search for a Range

问题描述Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is not found in th

2015-04-19 11:16:19 426

翻译 Trapping Rain Water

问题描述Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1],

2015-04-18 10:35:25 349

原创 Sudoku Solver

问题描述Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character ‘.’.You may assume that there will be only one unique solution.A sudoku puzzle… …an

2015-04-18 10:26:20 274

翻译 Bitwise AND of Numbers Range

问题描述Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the range [5, 7], you should return 4.思考:只要找到m和n的二进制表示中,最高的不同

2015-04-16 09:50:22 397

原创 Wildcard Matching

问题描述Implement wildcard pattern matching with support for ‘?’ and ‘*’.‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence).The matching should cover t

2015-04-14 11:03:46 415

原创 Permutations II

问题描述Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1].思考:

2015-04-13 10:55:32 251

原创 Permutations

问题描述Given a collection of numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].思考:递归求解想法1、设number为

2015-04-12 16:18:02 314

原创 Rotate Image

问题描述You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).For example: Input:  [[1, 2], [3, 4]] Output: [[3, 1], [4, 2]];思考:怎么变换使用O(1)的空间想法:先对矩阵进行对角线变

2015-04-12 15:39:41 277

原创 Anagrams

问题描述Given an array of strings, return all groups of strings that are anagrams. 即回文构词法 For example: Input:  [“tea”,”and”,”ate”,”eat”,”den”] Output: [“tea”,”ate”,”eat”]思考:怎么才能把一个单词的各个字母不按顺序比较想法1: 排

2015-04-12 10:48:40 255

原创 N-Queens

问题描述The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Each s

2015-04-10 14:48:34 296

原创 Spiral Matrix I && Spiral Matrix II

问题I描述Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Y

2015-04-10 13:10:19 340

原创 Jump Game

问题描述Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you

2015-04-10 10:50:25 289

原创 Permutation Sequence

问题描述The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3):“123” “132” “213” “231” “

2015-04-09 13:33:13 330

原创 Rotate List

问题描述Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL.思考:用两个指针A,B,A先走k步,然后A、B同时想法1、A先走k步,

2015-04-08 19:32:53 287

原创 Unique Paths & Unique Paths II

思考:Unique Path 可以用动态规划和排列组合解 Unique Path II 可以用动态规划想法1、对与问题一,排列组合考虑,要走到重点总共有n+m-2步,其中m-1步down和n-1步right,如果在m*n的方格内,选择m-1个down,那么剩下n-1步已经确定,并且唯一确定。所以问题一的解为C_(n+m-2)^(n-1)x_i^2

2015-04-08 18:54:24 357

原创 Number of Islands

思考:与Surrounded Regions类似方法利用num计数,遇到gird[i][j] = ‘1’,就让num++; 然后查看grid[i - 1][j]和grid[i - 1][j]。如果为1,则unit,在unit中,如果两个类的根不同,则num–;并且将两个类的根置为同一个。如grid[i - 1][j] == grid[i][j] == 1,则比较grid[i - 1][j]的根ro

2015-04-08 17:20:15 521

原创 Surrounded Regions

思考:只要将被包围的O和为被包围的O分开就好方法1、用 并查集(Union-find set)来区分2、用BFS将与边缘O相邻的O(为被包围的O)全部变为#(或者其他符号),然后对远数组更改代码块并查集public class Solution { int[] unitArray; //集合编号(隶属于哪一类) boolean[] edge; //是否被包围,每一类的ed

2015-04-08 16:16:53 579

原创 Binary Tree Right Side View

Binary Tree Right Side View思考:只需要知道每一行的最后一个节点值即可。方法1、考虑使用两个队列进行BFS,A队列存放当前行的节点,B队列存放当前节点的子节点,即当A队列空时,最后一个访问的节点即位当前行的最后一个节点。2、递归遍历。每一层都会有一个值加入列表,即可以利用DFS来遍历,并传入当前深度level(root为1),如果当前深度等于re(结果列表)的长度,即将

2015-04-08 12:02:38 399

2013年中国移动互联网用户研究报告_DCCI

2013年中国移动互联网用户研究报告,讨论中国互联网发展

2013-08-24

基于GIS技术的城市酒店空间分布研究

基于GIS技术的城市酒店空间分布研究,基于南京市酒店为例

2013-08-24

空空如也

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

TA关注的人

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