自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 从GIT上导入项目到idea 配置SSH 秘钥 过程 MAC版

1.终端配置git操作信息$ git config --global user.name "随便取名" $ git config --global user.email "GitHub邮箱"2. 终端输入命令生产key$ ssh-keygen -t rsa生成SSH key,下面三处直接回车就行3.通过上面路径Users/wangbo/.ssh找到id_rsa.pu...

2019-07-04 12:46:17 2334

原创 Best Time to Buy and Sell Stock(股票的价值系列 整理总结)

股票的最大价值I (leetcode 121)题目:假设把某股票的价格按照时间先后顺序存储再数组中,请问买卖该股票一次可能获得的最大利润是多少?例如,一只股票在某些时间节点的价格为{9,11,8,5,7,12,16,14}。如果5买入,16迈出,则利润为11.思路:定义一个函数diff(i) 表示为卖出价格为数组下标为i的元素时获得的最大利润。显然只要找到前i-1个数中最小的元素,就能算出当前的最...

2018-07-15 21:34:18 333

原创 Spring IOC AOP归纳总结

SpringAOP:面向切面编程(作用:将散布在系统中的公共问题集中解决 目的:用来降低耦合)基本概念:切面(Aspect):类似于OOP中的Class,一个Aspect存放一个系统功能的所有逻辑;在ApplicationContext中aop:aspect来配置;连接点(Joinpoint):连接点是一个应用执行过程中能够插入一个切面的点。如方法被调用时、抛出异常时;切入点的集合切入点(Poin...

2018-07-01 09:24:51 210

转载 生产者消费者模式中条件判断是使用while而不是if

永远在循环(loop)里调用 wait 和 notify,不是在 If 语句现在你知道wait应该永远在被synchronized的背景下和那个被多线程共享的对象上调用,下一个一定要记住的问题就是,你应该永远在while循环,而不是if语句中调用wait。因为线程是在某些条件下等待的——在我们的例子里,即“如果缓冲区队列是满的话,那么生产者线程应该等待”,你可能直觉就会写一个if语句。但if语句存...

2018-05-15 12:24:12 1176

原创 算法:n&(n-1)的总结

基本原理:      n&(n-1)作用:将n的二进制表示中的最低位为1的改为0,先看一个简单的例子:      n = 10100(二进制),则(n-1) = 10011 ==》n&(n-1) = 10000      可以看到原本最低位为1的那位变为0。以下几个应用:1. 求某一个数的二进制表示中1的个数(leetcode 191)class Solution {public...

2018-02-09 14:48:35 1524

转载 TCP协议中的三次握手和四次挥手(图解)

建立TCP需要三次握手才能建立,而断开连接则需要四次握手。整个过程如下图所示:先来看看如何建立连接的。【更新于2017.01.04 】该部分内容配图有误,请大家见谅,正确的配图如下,错误配图也不删了,大家可以比较下,对比理解效果更好。这么久才来更新,抱歉!!错误配图如下:首先Client端发送连接请求报文,Server

2017-12-29 17:34:36 286

原创 leetCode Single Number I II III

Single Number系列Single Number IGiven an array of integers, every element appears twice except for one. Find that single one.题目描述:给出一个数组arr,数组中每个元素都仅出现两次,除了其中一个数只出现一次,找出那个数。思想:主要的思想是用异或来

2017-12-08 15:11:29 332

原创 详解nginx反向代理+SwitchHost+Tomcat绑定域名配置总结

首先说下具体请求流程:假设客户端A--------》浏览器url请求域名--------》域名被host解析对应的IP--------》到对应IP的服务器--------》先被nginx反向代理拦截--------》找到nginx上一样域名(nginx.conf配置文件中server里的server_name)--------》对应的反向映射地址(nginx.conf配置文件中同左server

2017-10-30 19:43:11 2529

原创 LeetCode:Majority Element I II 投票算法

投票算法因为这两道题涉及到投票算法的思想,所以先从什么是投票算法入手。Boyer-Moore majority vote algorithm(摩尔投票算法)是一种在线性时间O(n)和空间复杂度的情况下,在一个元素序列中查找包含最多的元素。在它最简单的形式就是,查找最多的元素,也就是在输入中重复出现超过一半以上(n/2)的元素。如果序列中没有最多的元素,算法不能检测到正确结果

2017-10-22 19:04:13 813

原创 LeetCode Maximum Subarray Maximum Product Subarray DP问题

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 cont

2017-10-10 15:46:12 382

转载 LeetCode:Subsets I II

求集合的所有子集问题LeetCode:Subsets Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain

2017-09-28 15:03:02 361

原创 生产者消费者模式 JAVA

生产者消费者:为什么要用生产者消费者模式在多线程开发中,如果消费者的消费速度要大于生产者的生产速度,那么消费者必须等待生产者的生产才能继续消费。同样的如果生产者的生产速度大于消费者的消费速度,那么生产者需要等待消费者消费完再继续生产。生产者消费者模式是为了解决生产者消费者不均衡的问题而出现的。什么是生产者消费者模式通常设计模式都是高类聚低耦合的特性。因此生产者消费者模式是通过一个容

2017-08-27 18:13:33 873

转载 (error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on d

运行Redis时发生错误,错误信息如下:(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis

2017-08-25 14:22:51 436

原创 度度熊与邪恶大魔王(DP)C++ AC

1003度度熊与邪恶大魔王Problem Description度度熊为了拯救可爱的公主,于是与邪恶大魔王战斗起来。邪恶大魔王的麾下有n个怪兽,每个怪兽有a[i]的生命值,以及b[i]的防御力。度度熊一共拥有m种攻击方式,第i种攻击方式,需要消耗k[i]的晶石,造成p[i]点伤害。当然,如果度度熊使用第i个技能打在第j个怪兽上面的话,会使得第j个怪兽的生命值减少

2017-08-06 11:26:27 751

原创 大数相加,相减,相乘算法(JAVA代码)

415. Add StringsGiven two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 con

2017-07-26 15:49:06 2131

原创 231,338,326,Power of Two(Three,Four)Counting Bits 类似的技巧题

231. Power of TwoGiven an integer, write a function to determine if it is a power of two.题意:一个数是否 2的n次方的判断思想: 把该数n转换为2进制,与该数n-1进行&操作 可以判断出是否为2^nC++ AC代码:Time O(1) Space O(1)class

2017-07-23 14:49:48 389

原创 Combination Sum系列(I,II,III) dfs做的

39. Combination SumGiven a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same rep

2017-07-19 13:11:19 487

原创 565. Array Nesting(dfs 血的教训)

为什么说是血的教训呢,因为明明自己想的思路与那些AC的人思路一样而自己偏偏超时,又爆内存,觉得很奇怪,偏偏又找不出问题所在这道题,看完题意就知道dfs的思路了,却因为很小的细节卡了我2个小时!!!!! 泪崩

2017-07-16 22:26:24 918

转载 史上最全设计模式导学目录(完整版)

教我们的刘伟老师(欢迎大家搜索刘伟的博客)写的,写的特别好,并且讲课也是一流基础知识 设计模式概述从招式与内功谈起——设计模式概述(一):设计模式从何而来?从招式与内功谈起——设计模式概述(二):设计模式是什么?从招式与内功谈起——设计模式概述(三):设计模式有什么用?附:个人观点 面向对象设计原则面向对象设计原则概述

2017-07-14 15:31:51 625

原创 导入Maven Project项目获取jar包的流程 seeting配置

导入一个 Maven Project项目(前提要装好Maven管理工具,配置localRepo为本地仓库)首先 该项目会自动从localRepo(本地仓库)里查找pom.xml里所需要的jar包若localRepo本地没有 就会从你所配置的 中央仓库(或私服)去下载所需要的jar包并且包下好的jar放入localRepo里 该项目再从loclaRepo去拿如何通知项目去取

2017-07-11 17:44:20 2188

原创 88. 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 add

2017-07-09 20:15:56 295

原创 189. Rotate Array

Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].题意:一个简单的数组旋转,注意当k大于数组长度时,相当于对数组旋转k%len(数组长度)次

2017-07-07 16:46:16 261

原创 209. Minimum Size Subarray Sum

Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the

2017-07-07 15:44:56 277

原创 63. Unique Paths II

Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the

2017-07-05 14:16:55 247

原创 62. Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the

2017-07-05 14:07:22 300

原创 27. 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 in place with constant memo

2017-07-02 23:39:50 375

原创 628. Maximum Product of Three Numbers

题目:Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6Example 2:Input: [1,2,3,4]Output: 24

2017-07-02 23:27:05 1304

原创 162. Find Peak Element

A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in

2017-06-26 14:18:19 353

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

2017-06-26 14:11:12 403

原创 CodeM美团点评B轮:子串(E题) Java暴力解决

给出一个正整数n,我们把1..n在k进制下的表示连起来记为s(n,k),例如s(16,16)=123456789ABCDEF10, s(5,2)=11011100101。现在对于给定的n和字符串t,我们想知道是否存在一个k(2 ≤ k ≤ 16),使得t是s(n,k)的子串。 输入描述:第一行一个整数n(1 ≤ n ≤ 50,000)。第二行一个字符串t(长度 ≤ 1,000,0

2017-06-25 18:51:27 494

原创 540. Single Element in a Sorted Array

Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element that appears only once.Example 1:Input: [

2017-06-23 17:45:53 343

原创 219. Contains Duplicate II

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

2017-06-23 17:43:49 238

原创 119. Pascal's Triangle II

Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?Subscrib

2017-06-20 16:02:20 270

原创 118. 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]]思路:杨辉三角 很简单的逻辑判断 但看了某大神的代码 还

2017-06-19 12:41:49 325

原创 angluarjs flask 前后台数据交互传递 异步请求

作为python的初学者 找文档找资料 搞了一天多 终于知道后台flask与前台angluarjs如何数据的交互angluarjs数据的传值 主要是使用&http传值 AngularJS 应用组成如下:View(视图), 即 HTML。Model(模型), 当前视图中可用的数据。Controller(控制器), 即 JavaScript 函数,可以添加或修改属性。

2017-06-13 13:39:26 3585 1

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

2017-06-09 18:24:38 294

原创 53. 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] ha

2017-06-08 21:47:29 251

原创 169. 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 elemen

2017-06-08 20:59:55 471

原创 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-06-07 20:52:12 494

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

2017-06-07 20:48:32 410

空空如也

空空如也

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

TA关注的人

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