自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(332)
  • 资源 (1)
  • 收藏
  • 关注

原创 LeetCode 题解(291): Reverse Pairs

题目:Given an array nums, we call (i, j) an important reverse pair ifi and nums[i] > 2*nums[j].You need to return the number of important reverse pairs in the given array.Example1:Input: [1

2017-03-07 14:16:00 433

原创 判断一个给定字符序列在可以由该序列字符组成的所有序列里按Lexical

题目:Given a permutation which may contain repeated numbers, find its index in all the permutations of these numbers, which are ordered in lexicographical order. The index begins at 1.ExampleG

2015-12-01 03:49:25 628

原创 卖票

题目:有N个售票处,用一个N个元素的数组表示每个售票处剩余的票数,如N = 5, int[] numberOfTicketsRemain = {2, 3, 2, 5, 1}。其中某窗口当期票的价格等于该窗口当前所剩票的个数,如0号窗口目前剩两张票,则price[0][cur] = 2,如果0号窗口卖掉一张票,则还剩一张那么新的price[0][cur] = 1。给定总共要卖掉M张票。问最大收益

2015-11-26 04:44:53 550

原创 LeetCode 题解(290): Additive Number

题目:Additive number is a positive integer whose digits can form additive sequence.A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequen

2015-11-20 01:44:00 4013

原创 LeetCode 题解(289): Range Sum Query - Mutable

题目:Given an integer array nums, find the sum of the elements between indicesi and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at indexi to val.Ex

2015-11-19 06:59:40 708

原创 LeetCode 题解(288): Number of Islands II

题目:A 2d grid map of m rows and n columns is initially filled with water.We may perform anaddLand operation which turns the water at position (row, col) into a land.Given a list of positions to o

2015-11-18 04:44:02 3423

原创 找零的递归和循环实现,动态规划

题目:给一个面额,如100分,以及denominations,如1分,5分,10分,25分(每个denomination可以取任意多个),求该面额用这些denomiations的表示方法的个数。public class Solution { int makeChange(int n) { int[] denoms = {25, 10, 5, 1};

2015-11-16 06:40:14 481

原创 LeetCode 题解(287): Range Sum Query 2D - Immutable

题目:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1,col1) and lower right corner (row2, col2).The above rectangle (with the

2015-11-15 07:37:54 672

原创 LeetCode 题解(286): Range Sum Query - Immutable

题目:Given an integer array nums, find the sum of the elements between indicesi and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1

2015-11-15 07:26:00 382

原创 LeetCode 题解(285) :Remove Invalid Parentheses

题目:Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses ( a

2015-11-15 07:24:46 872

原创 LeetCode 题解(284) : Smallest Rectangle Enclosing Black Pixels

题目:An image is represented by a binary matrix with 0 as a white pixel and1 as a black pixel. The black pixels are connected, i.e., there is only one black region. Pixels are connected horizontal

2015-11-12 07:19:01 2252

原创 总结一下Word Break I 和 II

第一题:Given a string s and a dictionary of words dict, determine ifs can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict =

2015-11-12 06:19:34 525

原创 总结一下Rotated Sorted Array里找minimum或specific value

首先是找某一个值 target,并且数组里没有重复元素。找法是:如果 mid               如果 mid >= low 那么上半一定是排好序的,如果 low class Solution(object): def search(self, nums, target): """ :type nums: List[int]

2015-11-11 12:09:34 381

原创 Hackerrank (2): Snapdeal Hackathon > Cycling

题目:Problem StatementThe Snapdeal delivery people ride bikes to deliver products to various people around the city. There areN delivery people numbered 1 through N, and M bikes nu

2015-11-07 05:26:54 355

原创 LeetCode 题解(283) : Longest Increasing Subsequence

题目:Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101],

2015-11-05 05:41:46 345

原创 LeetCode 题解(282) : Bulls and Cows

题目:You are playing the following Bulls and Cows game with your friend: You write a 4-digit secret number and ask your friend to guess it. Each time your friend guesses a number, you give a hint.

2015-11-05 05:38:39 715

原创 Hackerrank (1): CodeStorm 2015 > Little Alexey's Tree

题目:Problem StatementLittle Alexey was playing with trees while studying powerful tree algorithms. Recently, he discovered a tree with n vertices. On each edge, there's a lowercase

2015-10-31 13:36:46 351

原创 LeetCode 题解(281) :Binary Tree Longest Consecutive Sequence

题目:Given a binary tree, find the length of the longest consecutive sequence path.The path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child c

2015-10-30 04:39:11 438

原创 LeetCode 题解(280) :Serialize and Deserialize Binary Tree

题目:Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection lin

2015-10-30 04:36:50 872

原创 LeetCode 题解(279) :Best Meeting Point

题目:A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. The distance i

2015-10-26 12:08:10 951

原创 LeetCode 题解(278) :Find Median from Data Stream

题目:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the m

2015-10-22 12:09:52 623

原创 再写String indexOf KMP算法

class Solution { /** * Returns a index to the first occurrence of target in source, * or -1 if target is not part of source. * @param source string to be scanned. * @param tar

2015-10-20 05:49:56 553

原创 LeetCode 题解(277) :Flip Game II

题目:You are playing the following Flip Game with your friend: Given a string that contains only these two characters:+ and -, you and your friend take turns to flip two consecutive "++" into "-

2015-10-18 04:43:35 1153

原创 LeetCode 题解(276) :Flip Game

题目:You are playing the following Flip Game with your friend: Given a string that contains only these two characters:+ and -, you and your friend take turns to flip two consecutive "++" into "-

2015-10-18 04:41:01 1237

原创 LeetCode 题解(275) : Nim Game

题目:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will

2015-10-18 04:39:31 310

原创 LeetCode 题解(274) : 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 n

2015-10-11 05:08:51 642

原创 LeetCode 题解(273) : Wiggle Sort

题目:Given an unsorted array nums, reorder it in-place such thatnums[0] = nums[2] .For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is[1, 6, 2, 5, 3, 4].题解:C++版:class So

2015-10-11 04:58:22 480

原创 LeetCode 题解(272) : Zigzag Iterator

题目:Given two 1d vectors, implement an iterator to return their elements alternately.For example, given two 1d vectors:v1 = [1, 2]v2 = [3, 4, 5, 6]By calling next repeatedly until hasNext r

2015-10-11 04:37:50 1180

原创 LeetCode 题解(271) : Word Pattern II

题目:Given a pattern and a string str, 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 substring in

2015-10-11 03:18:15 2649

原创 LeetCode 题解(270) : 3Sum Smaller

题目:Given an array of n integers nums and a target, find the number of index tripletsi, j, k with 0 that satisfy the conditionnums[i] + nums[j] + nums[k] .For example, given nums = [-2, 0, 1

2015-10-10 05:19:25 599

原创 LeetCode 题解(269) : Shortest Word Distance III

题目:This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same asword2.Given a list of words and two words word1 and word2, return the shortest distance

2015-10-09 13:30:04 576

原创 LeetCode 题解(268) : Shortest Word Distance II

题目:This is a follow up of Shortest Word Distance. The only difference is now you are given the list of words and your method will be calledrepeatedly many times with different parameters. How

2015-10-09 13:22:50 580

原创 LeetCode 题解(267) : Shortest Word Distance

题目:Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.For example,Assume that words = ["practice", "makes", "perfect", "codin

2015-10-09 13:18:28 448

原创 LeetCode 题解(266) : Inorder Successor in BST

题目:Given a binary search tree and a node in it, find the in-order successor of that node in the BST.Note: If the given node has no in-order successor in the tree, returnnull.题解:用了递归。循环应该略有

2015-10-09 13:07:28 857

原创 LeetCode 题解(265) : Count Univalue Subtrees

题目:Given a binary tree, count the number of uni-value subtrees.A Uni-value subtree means all nodes of the subtree have the same value.For example:Given binary tree, 5

2015-10-09 12:29:14 3946

原创 LeetCode 题解(264) : Verify Preorder Sequence in Binary Search Tree:

题目:Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.You may assume each number in the sequence is unique.Follow up:Could you do

2015-10-09 03:37:53 2179

原创 LeetCode 题解(263) : Find the Celebrity

题目:Suppose you are at a party with n people (labeled from 0 ton - 1) and among them, there may exist one celebrity. The definition of a celebrity is that all the othern - 1 people know him/her

2015-10-09 02:12:54 1882

原创 LeetCode 题解(262) : Reverse Words in a String II

题目:Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters.The input string does not contain leading or trailing spaces and the words are

2015-10-09 00:55:58 385

原创 LeetCode 题解(261) : Game of Life

题目: According to the Wikipedia's article: "The Game of Life, also known simply asLife, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a boar

2015-10-09 00:53:58 488

原创 LeetCode 题解(260) : Paint House II

题目:There are a row of n houses, each house can be painted with one of thek colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that n

2015-10-08 12:19:01 1313

ios+opencv 图像卡通化

iOS+opencv+xcode实现摄像头视频流的卡通化

2013-06-11

空空如也

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

TA关注的人

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