自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 java多线程实现

用Runnable还是Thread? 这个问题是上题的后续,大家都知道我们可以通过继承Thread类或者调用Runnable接口来实现线程,问题是,那个方法更好呢?什么情况下使用它?这个问题很容易回答,如果你知道Java不支持类的多重继承,但允许你调用多个接口。所以如果你要继承其他类,当然是调用Runnable接口好了。更多详细信息请点击这里。

2017-08-29 16:34:42 188

原创 310. Minimum Height Trees

For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini

2017-08-27 19:54:11 219

原创 309. Best Time to Buy and Sell Stock with Cooldown

Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on

2017-08-26 19:35:27 186

原创 306. Additive Number 自己写的,居然ac了,写一遍比看100遍强,看别人对边界的处理纯属浪费时间,不如自己动手,自己手写才能提高

Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the

2017-08-26 13:49:39 230

原创 304. Range Sum Query 2D - Immutable自己的已ac,但答案更好,开了一个稍大一点的空间,就不用判断临界条件了,好。

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 red bo

2017-08-26 13:00:53 173

原创 301. Remove Invalid Parentheses 我的没ac

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 ( and ).

2017-08-26 12:16:02 212

原创 299. Bulls and Cows 自己写已ac

class Solution { public: string getHint(string secret, string guess) { map mp; if(secret.size()==0)return ""; int a=0,b=0; string ss; for(int i=0;i<secret.s

2017-08-25 16:51:52 141

转载 295. 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 median

2017-08-25 15:52:56 168

原创 289. Game of Life

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

2017-08-24 20:17:19 360

原创 LeetCode(279)Perfect Squares

题目 Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n. For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n =

2017-08-24 12:37:16 214

原创 260不知为何ac不了

class Solution { public:     vector singleNumber(vector& nums) {         int flag1=0,flag2=0,a,b;         for(int i=0;i             if(flag1==0){                 a=nums[i];                 flag

2017-08-24 12:35:39 146

原创 260.Single Number III

题目:  Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Gi

2017-08-24 12:33:41 149

原创 282. Expression Add Operators

Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or *between the digits so they evaluate to the target value.

2017-08-24 10:08:08 146

原创 238. Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O

2017-08-22 13:38:51 160

原创 leetcode 233: Number of Digit One

Number of Digit One Total Accepted: 307 Total Submissions: 1853 Given an integer(整数) n, count the total number of digit(数字) 1 appearing in all non-negative(非负的) integers less than or equal to n.

2017-08-22 11:01:02 216

原创 188. Best Time to Buy and Sell Stock IV

/* * 188. Best Time to Buy and Sell Stock IV * 2016-6-6 by Mingyang * 这个题目我的做法是设立以为二维dp,T[i][j]i是transaction的数量,j是天数 * 也就是在j天以内完成i次交易的最大值 * T[i][j]=max 1. T[i][j-1]------>第j天

2017-08-19 18:48:30 237

原创 深度学习框架介绍

先概括一下深度学习的几大流行的框架:Pylearn2, Theano, Caffe, Torch, Cuda-covnet,Deeplarning4j等。 Theano是一个Python库,也是一个强大的数学表达式编译器。Pylearn2是在Theano基础上建立的机器学习库。用户可以用数学表达式写Pylearn2的插件(新的model, algorithm等), Theano将这些表达式进行优

2017-08-19 14:29:43 1015

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

2017-08-13 18:18:36 252

原创 Add to List 166. Fraction to Recurring Decimal

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses.

2017-08-13 16:58:34 213

原创 134. Gas Station

There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to

2017-08-10 17:31:26 159

原创 144. Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. /** * Definitio

2017-08-08 15:01:59 159

原创 96. Unique Binary Search Trees

【题目】 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

2017-08-04 22:11:44 141

原创 89. Gray Code

class Solution { public: vector grayCode(int n) { int x(1<<n); vector res; for(int i(0);i<x;i++){ //int tmp=1<<i;(意为i左移1位) int tmp=i<<1;

2017-08-04 16:47:08 134

原创 85. Maximal Rectangle

Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1

2017-08-03 22:20:20 178

原创 84. Largest Rectangle in Histogram

Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width o

2017-08-03 21:20:31 153

原创 81. Search in Rotated Sorted Array II

Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose an array sorted in ascending order is rotated a

2017-08-03 19:11:48 158

原创 79. Word Search

Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically

2017-08-03 16:09:02 183

原创 73. Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. class Solution { public:     void setZeroes(vector>& matrix) {         int col0=1,m=ma

2017-08-02 16:01:49 185

原创 Add to List 67. 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) {      

2017-08-01 20:18:24 189

空空如也

空空如也

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

TA关注的人

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