自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 leetcode题记——House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house

2018-03-07 13:27:44 150

原创 leetcode题记——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

2018-03-07 13:26:15 236

原创 leetcode题记——Number of 1 Bits

Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation 00000000

2018-03-02 23:08:56 141

原创 leetcode题记——Reverse Bits

Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110010

2018-03-02 23:03:52 141

原创 leetcode题记——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 ... Z...

2018-02-08 15:38:45 115

原创 leetcode题记——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 always...

2018-02-08 15:38:03 143

原创 leetcode题记——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...

2018-02-08 15:37:06 107

原创 leetcode题记——Two Sum II - Input array is sorted

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers su...

2018-02-08 15:36:09 144

原创 leetcode题记——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 ↘ c...

2018-02-08 15:35:15 107

原创 leetcode题记——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 { * int val; * ListNod...

2018-02-08 15:34:19 115

原创 leetcode题记——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 using extra mem...

2018-02-08 15:33:21 135

原创 leetcode题记——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 palindro...

2018-02-08 15:32:38 225

原创 leetcode题记——Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), des...

2018-02-08 15:31:46 127

原创 leetcode题记——Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]class Solution { public List<Li...

2018-02-08 15:30:21 133

原创 leetcode题记——Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum = 22...

2018-02-08 15:28:30 128

原创 leetcode题记——Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node./** * Definition for a binary tree node. ...

2018-02-08 15:26:19 122

原创 leetcode题记——Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never differ by...

2018-02-08 15:25:27 184

原创 leetcode题记——Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the t...

2018-02-08 15:23:50 129

原创 leetcode题记——Binary Tree Level Order Traversal II

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15,7], ...

2018-02-08 15:22:59 110

原创 leetcode题记——Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.For example:Given binary tree [3,9,20,null...

2018-02-08 15:22:04 149

原创 leetcode题记——Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the...

2018-02-08 15:21:19 140

原创 leetcode题记——Same Tree

Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example 1:In...

2018-02-08 15:19:25 123

原创 leetcode题记——Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional ...

2018-02-08 15:18:09 98

原创 leetcode题记——Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3./** * D...

2018-02-08 15:17:32 198

原创 leetcode题记——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?Note: Given n will be a positive int...

2018-02-08 15:16:15 116

原创 leetcode题记——Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".class Solution { public String addBinary(String a, String b) { if(a.length()<b....

2018-02-08 15:15:05 135

原创 leetcode题记——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 digits are s...

2018-02-08 15:14:19 102

原创 leetcode题记——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 defined a...

2018-02-08 15:13:02 124

原创 leetcode题记——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] has the ...

2018-02-08 15:11:14 124

原创 leetcode题记——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.Exam...

2018-02-08 15:10:18 120

原创 leetcode题记——Implement strStr()

Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll" Output: 2 Example 2:Input:...

2018-02-08 15:08:16 115

原创 leetcode题记——Remove Element

Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place ...

2018-02-08 15:06:20 130

原创 leetcode题记——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 by modifying the ...

2018-02-08 15:05:24 89

原创 leetcode题记——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.Example:Input: 1->2->4, 1->3->4 Output: 1->1...

2018-02-08 15:04:06 127

原创 leetcode题记——Longest Common Prefix

write a function to find the longest common prefix string amongst an array of stringsclass Solution { public String longestCommonPrefix(String[] strs) { if(strs.length==0) return ""; ...

2018-02-08 15:01:47 168

原创 leetcode题记——Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.class Solution { public boolean isPalindrome(int x) { int a = x, h = 1; if (a < 0) return false;//排除负数 ...

2018-02-08 14:59:55 112

原创 leetcode题记——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 the sam

2017-09-25 23:13:14 138

原创 leetcode题记——Reverse Integer

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 思路:对数x从个位数逐步往前,先取余后除以10,需要注意的是java中integer数的范围是2^31-1至-2^31之间,倒序后可能会出现值溢出的情况,需要用long数值(java中的范围为2

2017-09-25 23:04:39 138

原创 leetcode题记——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

2017-09-25 22:52:34 130

空空如也

空空如也

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

TA关注的人

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