自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Array Partition I

Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as poss...

2018-03-08 22:44:50 299

原创 617. Merge Two Binary Trees

Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree...

2018-03-08 22:31:21 207

原创 leetcode 413. Arithmetic Slices(medium)

A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequenc

2017-04-21 15:56:28 373

原创 leetcode 506. Relative Ranks(easy)

Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".Example 1:In

2017-04-20 15:12:08 308

原创 leetcode 541. Reverse String II(easy)

Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of th

2017-04-20 11:46:53 409

原创 leetcode 504. Base 7(easy)

Given an integer, return its base 7 string representation.Example 1:Input: 100Output: "202"Example 2:Input: -7Output: "-10"Note: The input will be in range of [-1e7, 1e

2017-04-20 10:20:24 318

原创 leetcode 492. Construct the Rectangle(easy)

Total Accepted: 14611Total Submissions: 29825Difficulty: EasyContributors:love_FawnFor a web developer, it is very important to know how to design a web page's size. So, given a specific recta

2017-04-19 15:31:22 329 1

原创 leetcode 530. Minimum Absolute Difference in BST(easy)

Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.Example:Input: 1 \ 3 / 2Output:1Explanation:Th

2017-04-18 16:02:53 247

原创 leetcode 520. Detect Capital(easy)

Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in t

2017-04-18 15:44:31 351

原创 leetcode 485. Max Consecutive Ones(easy)

Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutiv

2017-04-18 15:25:54 273

原创 leetcode 500. Keyboard Row(easy)

Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.Example 1:Input: ["Hello", "Alaska", "Da

2017-04-17 17:01:46 277

原创 leetcode 557. Reverse Words in a String III(easy)

Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contes

2017-04-17 16:28:09 436

原创 leetcode.55.Jump Game(medium)[贪心算法]

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-12-23 16:23:13 380

原创 leetcode 461.Hamming Distance(easy)[位运算]

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note:0 ≤ x, 

2016-12-21 11:37:04 385

原创 leetcode 434.Number of Segments in a String(easy)[分割字符串]

Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note that the string does not contain any non-printable characters.

2016-12-17 17:24:55 347

原创 455.leetcode Assign Cookies(easy)[数组处理]

Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a c

2016-12-16 15:59:25 377

原创 463.leetcode Island Perimeter(easy)[二维数组处理]

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 completely

2016-12-14 16:43:01 370

原创 412.leetciode Fizz Buzz(easy)[字符串 整数处理]

Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.

2016-12-14 15:58:44 233

原创 315.leetcode Count of Smaller Numbers After Self(hard)[利用二分查找 空间换取时间的思想]

You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].Example

2016-10-08 21:08:56 378

原创 396.leetcode Rotate Function(easy)[找规律]

Given an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a "rotation function" F on A as follow:

2016-10-08 19:46:41 239

原创 334.leetcode Increasing Triplet Subsequence(medium)[巧妙的方法减少时间与空间复杂度]

Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there exists i, j, k such that arr[i] ar

2016-10-07 21:47:16 258

原创 397.leetcode Integer Replacement(easy)[数字处理 溢出]

Given a positive integer n and you can do operations as follow:If n is even, replace n with n/2.If n is odd, you can replace n with either n + 1 or n - 1.What is the minimum number o

2016-10-07 21:11:45 277

原创 409.leetcode Longest Palindrome(easy)[字符串处理 最长回文]

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 con

2016-10-07 16:48:57 316

原创 371.leetcode Sum of Two Integers(easy)[异或 与运算处理]

Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.两个数相加但是不能用+、-运算符则考虑从位运算的角度来解决问题,观察二进制加法的特点,如果没有进位的时候结果是

2016-10-07 16:00:05 234

原创 404.leetcode Sum of Left Leaves(easy)[二叉树 递归]

Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24

2016-10-07 15:34:18 218

原创 389.leetcode Find the Difference(easy)[字符串处理]

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

2016-10-07 15:21:51 213

原创 401.leetcode Binary Watch(easy)[递归回溯]

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significant bit o

2016-09-22 20:48:24 568

原创 264.leetcode Ugly Number II(medium)[寻找第N个丑数]

Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 

2016-09-22 19:52:42 573

原创 394.leetcode Decode String(medium)[栈 字符串]

iven an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is

2016-09-09 10:40:38 328

原创 96.leetcode Unique Binary Search Trees(meidum)[动态规划]

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \

2016-09-07 21:43:10 239

原创 392.leetcode Is Subsequence (medium)[判断一个字符串是否是另一个字符串的子串]

Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) strin

2016-09-07 21:05:39 1915

原创 翻转数组

翻转数组题目描述给定一个长度为n的整数数组a,元素均不相同,问数组是否存在这样一个片段,只将该片段翻转就可以使整个数组升序排列。其中数组片段[l,r]表示序列a[l], a[l+1], ..., a[r]。原始数组为a[1], a[2], ..., a[l-2], a[l-1], a[l], a[l+1], ..., a[r-1], a[r], a[r+1], a[r+2]

2016-09-04 21:14:57 2246

原创 股神

股神题目描述有股神吗?有,小赛就是!经过严密的计算,小赛买了一支股票,他知道从他买股票的那天开始,股票会有以下变化:第一天不变,以后涨一天,跌一天,涨两天,跌一天,涨三天,跌一天...依此类推。为方便计算,假设每次涨和跌皆为1,股票初始单价也为1,请计算买股票的第n天每股股票值多少钱?输入输入包

2016-09-04 20:58:04 1203

原创 124.leetcode Binary Tree Maximum Path Sum(hard)[先序遍历]

Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The

2016-08-26 21:30:05 403

原创 129.leetcode Sum Root to Leaf Numbers(medium)[深度遍历DFS]

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the tota

2016-08-26 21:00:12 380

原创 113.leetcode Path Sum II(meidum)[DFS加回溯 ]

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \

2016-08-26 16:59:14 393

原创 24.leetcode Merge k Sorted Lists(hard)[归并k个有序链表]

其实整体思想和归并k个有序数组是一样的,有三种方法,效率最慢的是两个有序链表和并之后再与其他链表合并,需要合并n-1次。第二种方法是两两一组分别归并,第三种方法是采用一个k大小的堆,刚开始的时候将每个链表的第一个元素都放入k的最小堆中,那么就可以直接得到k中最小的值,再将k中刚取出的最小值的下一个节点加入堆中,直到所有的元素都处理完成。/** * Definition for singly-

2016-08-26 15:55:36 496

原创 83.leetcode Remove Duplicates from Sorted List(easy)[链表删除重复部分]

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.class Solution {public

2016-08-26 11:38:28 321

原创 82.leetcode Remove Duplicates from Sorted List II(medium)[链表删除重复]

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->

2016-08-26 11:36:02 248

原创 34.leetcode Search for a Range(meidum)[二分查找]

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-08-26 11:05:47 210

空空如也

空空如也

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

TA关注的人

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