自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 7. Reverse Integer

题目Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321我的解答public class Solution { public int reverse(int x) { int max = Integer.MAX_VALUE;

2017-02-28 23:49:37 199

原创 9. Palindrome Number

题目Determine whether an integer is a palindrome. Do this without extra space.我的解法public class Solution { public boolean isPalindrome(int x) { if(x < 0) return false;

2017-02-28 17:35:26 166

原创 13. Roman to Integer(不懂规则)

题目Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.搞不懂换算规则。。。。

2017-02-28 16:26:57 204

原创 66. Plus One

题目Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The

2017-02-28 15:28:03 240

原创 67. Add Binary

题目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)

2017-02-28 11:28:58 162

原创 69. Sqrt(x)

题目Implement int sqrt(int x).Compute and return the square root of x.我的解法public class Solution { public int mySqrt(int x) { int s = 1; int e = x; long mid = 0;

2017-02-28 10:29:03 222

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

2017-02-27 21:12:00 189

原创 171. Excel Sheet Column Number

题目Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:    A -> 1    B -> 2    C -> 3    .

2017-02-27 20:03:02 187

原创 172. Factorial Trailing Zeroes

题目Given an integer n, return the number of trailing zeroes inn!.我的解法(超时)public class Solution { public int twoNum = 0; public int fiveNum = 0; public int trailingZeroes

2017-02-27 19:40:11 163

原创 231. Power of Two

题目Given an integer, write a function to determine if it is a power of two.我的解法public class Solution { public boolean isPowerOfTwo(int n) { if(n == 0) return false;

2017-02-27 12:00:49 165

原创 258. Add Digits

题目Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like:3 + 8 = 11, 1 + 1 = 2. Since2 has only

2017-02-27 11:47:50 169

原创 263. Ugly Number

题目Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example, 6, 8 are ugly while14 is not ugly

2017-02-27 11:13:10 151

原创 268. Missing Number

题目Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.我的解法public class So

2017-02-27 10:48:32 141

原创 367. Valid Perfect Square

题目Given a positive integer num, write a function which returns True ifnum is a perfect square else False.Note: Do not use any built-in library function such assqrt.Example 1:Input: 16R

2017-02-26 18:52:59 177

原创 400. Nth Digit

题目Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:n is positive and will fit within the range of a 32-bit signed integer (n 31).Example 1:Inp

2017-02-26 15:11:23 202

原创 415. Add Strings

题目Given two non-negative integers num1 andnum2 represented as string, return the sum ofnum1 and num2.Note:The length of both num1 andnum2 is Both num1 andnum2 contains only digits

2017-02-24 17:54:09 421

原创 453. Minimum Moves to Equal Array Elements

题目Given a non-empty integer array of sizen, find the minimum number of moves required to make all array elements equal, where a move is incrementingn - 1 elements by 1.Example:Input:[1,2

2017-02-24 12:03:43 190

原创 1. Two Sum

题目Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use t

2017-02-23 19:56:46 81

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

2017-02-23 17:38:39 155

原创 204. Count Primes

题目Description:Count the number of prime numbers less than a non-negative number,n.我的解法(超时)public class Solution { public int countPrimes(int n) { int res = 0; if(n - 1

2017-02-23 16:37:36 134

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

2017-02-23 10:11:25 157

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

2017-02-22 22:43:15 135

原创 219. Contains Duplicate II

题目Given an array of integers and an integer k, find out whether there are two distinct indicesi and j in the array such that nums[i] = nums[j] and theabsolute difference between i and j is at

2017-02-22 17:56:20 142

原创 242. Valid Anagram

题目Given two strings s and t, write a function to determine ift is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may

2017-02-22 16:08:17 220

原创 290. Word Pattern

题目Given a pattern and a stringstr, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter inpattern and a non-empty word instr

2017-02-22 14:02:31 175

原创 349. Intersection of Two Arrays

题目Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1],nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The re

2017-02-22 11:17:28 142

原创 350. Intersection of Two Arrays II

题目Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1],nums2 = [2, 2], return [2, 2].Note:Each element in the result should appear as m

2017-02-21 22:15:03 134

原创 389. Find the Difference

题目Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling strings and then add one more letter at a random position.Find the letter that

2017-02-21 18:19:49 156

原创 409. Longest Palindrome

题目Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is not

2017-02-21 16:44:30 138

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

2017-02-21 10:26:59 84

原创 438. Find All Anagrams in a String(不太懂)

题目Given a string s and a non-empty string p, find all the start indices ofp's anagrams in s.Strings consists of lowercase English letters only and the length of both stringss and p will no

2017-02-21 00:08:44 161

原创 447. Number of Boomerangs

题目Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points(i, j, k) such that the distance betweeni and j equals the distance betweeni and k (the order

2017-02-20 16:14:50 162

原创 463. Island Perimeter

题目You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is compl

2017-02-20 11:27:30 174

原创 476. Number Complement

题目Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guaranteed to fit within the rang

2017-02-19 23:42:52 179

原创 461. Hamming Distance

题目The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x andy, calculate the Hamming distance.我的解法publi

2017-02-18 16:54:39 193

原创 java整型类型

1、整数的表示方式数值表示:123,二进制表示0b00001111。在Java中,这两种写法写出一个整数值时,默认是int类型,即用32比特内存空间来存储。若末尾加L,则是long类型,用64比特内存空间存储。2、byte、short、int、long类型的转换a、把int类型的值赋值给byte、short类型变量时,如值在byte、short的取值范围内,则自动转换成那个类型,存

2017-02-18 15:44:01 4034 1

原创 21. 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.我的解法/** * Definition for singly-linked list. *

2017-02-17 20:20:05 134

原创 83. Remove Duplicates from Sorted List

题目Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given 1->1->2, return1->2.Given 1->1->2->3->3, return1->2->3.我的解法/** * Defin

2017-02-17 12:34:05 129

原创 141. 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?答案(两指针法)/** * Definition for singly-linked list. * class ListNode { * i

2017-02-16 19:05:55 139

原创 160. Intersection of Two Linked Lists

题目Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A:          a1 → a2                   ↘      

2017-02-16 17:28:37 145

空空如也

空空如也

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

TA关注的人

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