自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".这道题目与[url=http://kickcode.iteye.com/blog/2273549]Add Two Numbers [/url]这道题目类似。不同...

2016-01-31 13:26:29 56

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.旋转一个链表,首先我们计算出链表的长度len,如果k % len ...

2016-01-31 06:57:35 47

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""23...

2016-01-31 06:27:37 85

原创 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 d...

2016-01-31 05:46:10 103

原创 Rotate Image

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?旋转一个n * n的二维数组,要求in-place完成。in-place的意思就是不要开辟额外的空间。...

2016-01-31 05:22:37 56

面向对象中的多态

在说多态之前,我们先看一段代码:[code="java"]package JavaInterview;class A { int i; public A() { i = 3; System.out.println(i); } void display() { Syste...

2016-01-30 15:43:08 143

原创 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 i...

2016-01-30 14:34:37 96

原创 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,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha...

2016-01-30 14:19:23 60

原创 Pow(x, n)

Implement pow(x, n). x is double type and n is a integer type.这是一道设计题,实现pow方法。主要考察对细节的处理,比如当n为负数时我们应该如何处理,仅仅是将n变为正数取倒数吗,如果当n为MIN_VALUE就会溢出,这种情况我们就要单独处理。此外我们通过右移来提高运算速度,每右移一次,x都加倍。实现代码如下:[code="j...

2016-01-30 14:03:34 58

Group Anagrams 异位构词

Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], [&qu

2016-01-30 12:26:35 307

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

2016-01-29 04:01:01 44

原创 Permutations

Given a collection of distinct 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].全排列的问题...

2016-01-29 03:00:22 53

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

2016-01-29 02:45:48 159

原创 Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combinati...

2016-01-29 02:27:37 50

Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number...

2016-01-29 02:23:00 93

Count and Say

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one...

2016-01-28 02:37:37 59

Valid Sudoku 数独

Determine if a Sudoku is valid. The Sudoku board could be partially filled, where empty cells are filled with the character '.'.[img]https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Sudoku-...

2016-01-28 02:26:28 157

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

2016-01-28 02:20:55 53

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

2016-01-28 02:11:57 58

Search 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).You are given a target value to search. If found in the array return ...

2016-01-28 01:54:42 156

Next Permutation 全排列

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

2016-01-27 02:39:11 58

Divide Two Integers

Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题目要求我们不用乘法,除法还有模运算来完成两个整数的除运算。如果溢出时返回最大值。题目要求返回一个整型,当除数为Integer.MIN_VALUE,被除数为...

2016-01-27 02:20:40 78

原创 Remove Element

Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.这...

2016-01-27 02:12:01 92

原创 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.Do not allocate extra space for another array, you must do this in place with...

2016-01-27 02:07:30 45

原创 Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.这道题目实际上就是让我们实现java中的indexOf方法,有关字符串匹配的问题,有一个时间复杂为线性时间的算法-KMP,这里我们使用j...

2016-01-27 02:05:35 41

原创 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 valid ...

2016-01-26 02:01:09 44

原创 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 linke...

2016-01-26 01:49:24 62

原创 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.题目的意思是给定两个有序的链表,将它们合并为一个有序的链表。思路比较简单,依次比较两个节点值得大小,每次取...

2016-01-26 01:46:46 51

原创 Container With Most Water

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two ...

2016-01-26 00:58:06 37

原创 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:"((()))", "(()())", "(())()", "()(())", "()()()...

2016-01-26 00:57:00 41

原创 Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.[img]https://upload....

2016-01-25 05:37:40 57

原创 Longest Common Prefix 最长公共前缀

Write a function to find the longest common prefix string amongst an array of strings.题目的要求是给定一个字符串数组,在所有字符串中找到最长的公共前缀。对边界情况的解决,如果数组为空,那么就返回0。我们取出第一个元素,然后依次取第一个元素包含的字符,将这个字符与剩余的字符串相比,看在同一位置上是否相同...

2016-01-25 05:36:50 55

原创 Palindrome Number 回文数

Determine whether an integer is a palindrome. Do this without extra space.判断一个数是否为回文数。我们需要知道的负数不属于回文数。可以有很多种思路解决这道题。可以把这个整数转换成字符串,然后用双指针进行比较;也可以将这个整数反转,然后对比反转后是否和原来的数相同。第一种方法不用考虑整数越界问题,用第二种方法的时候要注...

2016-01-25 03:38:44 60

原创 Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.我们做过[url=http://kickcode.iteye.com/admin/blogs/2273558]Integer to Roman [/url]这道题目,在里面讲了...

2016-01-25 03:28:45 45

原创 Integer to Roman

Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.解决这道题目的关键在于了解罗马数字的规则。罗马数字共有7个,即I(1),V(5),X(10),L(50),C(100),D(500),M(1000)。相同的1个罗马数字重复...

2016-01-25 03:25:41 91

原创 Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321这是一道比较简单的题目,但也是面试中容易考到的题目,主要考察我们对于整数越界时的处理,我们要根据题目的要求进行不同的处理。这个题目要求我们返回一个int型的整数,因此我们对于越界的数统一返回一个合理的整...

2016-01-24 09:37:29 46

原创 ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA ...

2016-01-24 09:25:11 50

Longest Palindromic Substring(最长回文子串)

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.题目的要求是给定一个字符串,找到一个最长的回...

2016-01-24 08:02:49 159

Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For ...

2016-01-24 07:47:09 95

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

2016-01-24 07:33:33 110

空空如也

空空如也

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

TA关注的人

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