自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Happy Number

Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares

2015-06-19 10:29:17 344

原创 Rotate Array

Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solutions as yo

2015-06-19 09:18:04 324

原创 Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a

2015-06-18 16:50:41 297

原创 Rectangle Area

Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the tota

2015-06-17 11:28:36 353

原创 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 that the array is non-empty and the majority element

2015-06-16 22:24:55 340

原创 Count Primes

最主要的是对素数的倍数进行处理,时间复杂度大大降低;for (int j = i * i; j < n; j += i) { isPrime[j] = false; }Description:Count the number of prime numbers less than a non-negative number, n.

2015-06-16 09:07:40 453

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

2015-06-16 08:56:22 336

原创 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 array, and it should return false if every element

2015-06-16 07:52:41 304

原创 Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille

2015-06-16 07:18:47 248

原创 Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get

2015-06-12 19:50:10 226

原创 艾森哲面试 Accenture

早上8点45到达软件园24号楼11层,本来时9点开始面试,一直等到9点30,面试官才匆匆来到。通知我们到会议室面试。面试开始才知道是群面+英语面:开始50分钟全部用英语1.自我介绍(两分钟):我觉得重要的是   第一步,介绍自己;第二步,说技术,让面试官知道自己精通XXXX,熟悉XXXX,了解XXXX,对XXXX在XXXX环境下的XXXX有深入的认识。    第三步,说

2015-06-11 13:01:29 1687

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

2015-06-10 13:52:58 246

原创 Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB Credits

2015-06-10 10:53:30 272

原创 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?即求菲波拉契数列,第一次publ

2015-06-10 08:58:40 338

原创 Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".wa了很多次,进位考虑的不仔细。package leetcode;public class AddBinary {pub

2015-06-09 21:53:14 393

原创 Plus One

Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.给你一个非负数的整形数组,加

2015-06-09 14:06:32 327

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

2015-06-09 12:58:04 223

原创 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.考察对有序链表的使用,归并。package leetcode;public

2015-06-09 12:09:08 325

转载 字符串匹配的KMP算法

字符串匹配的KMP算法作者: 阮一峰日期: 2013年5月 1日字符串匹配是计算机的基本任务之一。举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里面是否包含另一个字符串"ABCDABD"?许多算法可以完成这个任务,Knuth-Morris-Pratt算法(简称KMP)是最常

2015-06-09 07:40:47 292

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

2015-06-08 09:43:00 277

转载 Java中的String类常量池详解

从一个博客上看到的6个题,先看看吧,如果都会了,这部分的知识就掌握的不错啦!输出结果在代码注释后面:test1:package StringTest;public class test1 { /** * @param args */ public static void main(String[] args){ String

2015-06-08 09:10:28 381

原创 Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the function had been updat

2015-06-08 08:24:07 325

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

2015-06-07 16:33:56 322

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

2015-06-07 16:15:13 249

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

2015-06-07 15:47:25 248

原创 Longest Common Prefix

Longest Common Prefix Total Accepted: 49556 Total Submissions: 192089My SubmissionsQuestion Solution Write a function to find the longest common prefix string amongst an array of

2015-06-06 13:29:45 282

原创 Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.了解规则,进行运算。基本字符IVXLCDM相

2015-06-06 13:01:42 284

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

2015-06-06 09:14:42 276

原创 String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2015-06-06 08:15:57 611

原创 Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting th

2015-06-06 07:23:01 288

原创 ZigZagConversion

P A H NA P L S I I GY I RAnd then read line by line: "PAHNAPLSIIGYIR"Write the code that will take a string and make this conversion given a number of rows:string convert(stri

2015-06-05 11:34:02 328

空空如也

空空如也

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

TA关注的人

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