自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(221)
  • 资源 (1)
  • 收藏
  • 关注

原创 *******地图分析

你现在手里有一份大小为N x N 的 网格 grid,上面的每个 单元格 都用0和1标记好了。其中0代表海洋,1代表陆地,请你找出一个海洋单元格,这个海洋单元格到离它最近的陆地单元格的距离是最大的。我们这里说的距离是「曼哈顿距离」(Manhattan Distance):(x0, y0) 和(x1, y1)这两个单元格之间的距离是|x0 - x1| + |y0 - y1|。如果网格上只有陆地或者海洋,请返回-1。示例 1:输入:[[1,0,1],[0,0,0...

2020-12-10 18:26:13 288 1

原创 ****可能的二分法

给定一组N人(编号为1, 2, ..., N),我们想把每个人分进任意大小的两组。每个人都可能不喜欢其他人,那么他们不应该属于同一组。形式上,如果 dislikes[i] = [a, b],表示不允许将编号为 a 和 b 的人归入同一组。当可以用这种方法将所有人分进两组时,返回 true;否则返回 false。示例 1:输入:N = 4, dislikes = [[1,2],[1,3],[2,4]]输出:true解释:group1 [1,4], group2 [2,3]...

2020-12-06 17:12:44 235 1

原创 ****重新安排行程

给定一个机票的字符串二维数组 [from, to],子数组中的两个成员分别表示飞机出发和降落的机场地点,对该行程进行重新规划排序。所有这些机票都属于一个从 JFK(肯尼迪国际机场)出发的先生,所以该行程必须从 JFK 开始。提示:如果存在多种有效的行程,请你按字符自然排序返回最小的行程组合。例如,行程 ["JFK", "LGA"] 与 ["JFK", "LGB"] 相比就更小,排序更靠前所有的机场都用三个大写字母表示(机场代码)。假定所有机票至少存在一种合理的行程。所有的机票必须都用一次.

2020-12-03 14:48:13 213

原创 ***判断二分图

给定一个无向图graph,当这个图为二分图时返回true。如果我们能将一个图的节点集合分割成两个独立的子集A和B,并使图中的每一条边的两个节点一个来自A集合,一个来自B集合,我们就将这个图称为二分图。graph将会以邻接表方式给出,graph[i]表示图中与节点i相连的所有节点。每个节点都是一个在0到graph.length-1之间的整数。这图中没有自环和平行边:graph[i]中不存在i,并且graph[i]中没有重复的值。示例 1:输入: [[1,3], [0,2], [1,3], ..

2020-11-30 15:18:39 89

原创 **概率最大的路径

给你一个由 n 个节点(下标从 0 开始)组成的无向加权图,该图由一个描述边的列表组成,其中 edges[i] = [a, b] 表示连接节点 a 和 b 的一条无向边,且该边遍历成功的概率为 succProb[i] 。指定两个节点分别作为起点 start 和终点 end ,请你找出从起点到终点成功概率最大的路径,并返回其成功概率。如果不存在从 start 到 end 的路径,请 返回 0 。只要答案与标准答案的误差不超过 1e-5 ,就会被视作正确答案。示例 1:输入:n = 3, .

2020-11-26 18:03:33 388

原创 **阈值距离内邻居最少的城市

有 n个城市,按从 0 到 n-1编号。给你一个边数组edges,其中 edges[i] = [fromi, toi, weighti]代表fromi和toi两个城市之间的双向加权边,距离阈值是一个整数distanceThreshold。返回能通过某些路径到达其他城市数目最少、且路径距离 最大 为distanceThreshold的城市。如果有多个这样的城市,则返回编号最大的城市。注意,连接城市 i 和 j 的路径的距离等于沿该路径的所有边的权重之和。示例 1:输...

2020-11-24 15:49:44 133

原创 **课程表 II

现在你总共有 n 门课需要选,记为0到n-1。在选修某些课程之前需要一些先修课程。例如,想要学习课程 0 ,你需要先完成课程1 ,我们用一个匹配来表示他们: [0,1]给定课程总量以及它们的先决条件,返回你为了学完所有课程所安排的学习顺序。可能会有多个正确的顺序,你只要返回一种就可以了。如果不可能完成所有课程,返回一个空数组。示例1:输入: 2, [[1,0]]输出: [0,1]解释:总共有 2 门课程。要学习课程 1,你需要先完成课程 0。因此,正确的课程顺序为 [...

2020-11-21 13:31:46 96

原创 **课程表 II

你这个学期必须选修 numCourse 门课程,记为0到numCourse-1 。在选修某些课程之前需要一些先修课程。例如,想要学习课程 0 ,你需要先完成课程 1 ,我们用一个匹配来表示他们:[0,1]给定课程总量以及它们的先决条件,请你判断是否可能完成所有课程的学习?示例 1:输入: 2, [[1,0]]输出: true解释:总共有 2 门课程。学习课程 1 之前,你需要完成课程 0。所以这是可能的。示例 2:输入: 2, [[1,0],[0,1]]输出: ...

2020-11-20 18:16:50 127

原创 ××将 x 减到 0 的最小操作数

给你一个整数数组nums和一个整数x。每一次操作时,你应当移除数组nums最左边或最右边的元素,然后从x中减去该元素的值。请注意,需要修改数组以供接下来的操作使用。如果可以将x恰好减到0,返回最小操作数;否则,返回-1。示例 1:输入:nums = [1,1,4,2,3], x = 5输出:2解释:最佳解决方案是移除后两个元素,将 x 减到 0 。BFS,超时class Solution { public int m...

2020-11-15 12:27:49 363

原创 **确定两个字符串是否接近

如果可以使用以下操作从一个字符串得到另一个字符串,则认为两个字符串接近:操作 1:交换任意两个现有字符。 例如,abcde-> aecdb 操作 2:将一个现有字符的每次出现转换为另一个现有字符,并对另一个字符执行相同的操作。 例如,aacabb->bbcbaa(所有a转化为b,而所有的b转换为a) 你可以根据需要对任意一个字符串多次使用这两种操作。给你两个字符串,word1和word2。如果word1和word2接近...

2020-11-15 12:15:27 113

原创 **跳跃游戏 II

给定一个非负整数数组,你最初位于数组的第一个位置。数组中的每个元素代表你在该位置可以跳跃的最大长度。你的目标是使用最少的跳跃次数到达数组的最后一个位置。示例:输入: [2,3,1,1,4]输出: 2解释: 跳到最后一个位置的最小跳跃数是 2。 从下标为 0 跳到下标为 1 的位置,跳1步,然后跳3步到达数组的最后一个位置。说明:假设你总是可以到达数组的最后一个位置。class Solution { public int jump(int[] nums...

2020-11-13 18:06:40 94

原创 **监控二叉树

给定一个二叉树,我们在树的节点上安装摄像头。节点上的每个摄影头都可以监视其父对象、自身及其直接子对象。计算监控树的所有节点所需的最小摄像头数量。难点在于递归过程中,节点共有三种状态。class Solution { int res = 0; public int minCameraCover(TreeNode root) { if(root == null) return 0; if(helper(root) == 2) res+..

2020-11-11 16:46:35 82

原创 算法整理

二叉树:1 Search Range in Binary Search Tree:找到二叉树中所有在K1到K2的数。DFS遍历,判断在范围内后入list。3 Binary Tree Level Order Traversal I/II:1.从上到下,zigzag方式。2.从下到上,顺序展示Construct Binary Tree from Inorder and Postorder Tr...

2019-01-16 17:58:41 131

原创 eclipse 运行maven工程出现Missing artifact jdk.tools:jdk.tools:jar:1.7问题

网上查了很多帖子,大部分都是说在pom中引入依赖包就可以解决问题。但是感觉没有从根本上解决。其实出现这个异常的原因是因为maven找不到jdk.tool,这个jar包只存在于jdk的bin路径下,假如eclipse中定位的路径是jre路径,那么自然找不到这个库。这有两种可能性1,path路径下java_home指向了jre路径,这种情况大部分因为自动安装jdk或者自动更新jdk导致。2,eclip...

2018-04-01 12:10:47 544

原创 区块链书单

区块链技术指南

2018-01-26 14:44:06 253

原创 MongoDB 数据快速写入问题

在进行MongoDB大数据量写入的情况下,Mongo同步出现过很多问题。简单记录一下:同步数据过慢:可参考https://yq.aliyun.com/articles/47336同步数据异常导致占用连接池资源:sharded connection to xxx not being returned to the poolSHARDING [conn32380] could not

2017-11-04 10:28:04 4133

原创 面试书单

Java虚拟机规范(JavaSE7).pdf

2017-09-07 15:31:34 351

原创 [Lintcode]Wildcard Matching 通配符匹配

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cove

2017-07-11 22:54:38 317

原创 Golang内存模型解析-2

Channel通信:1)Channel的发送和接收,满足Happen-before。(废话)var c = make(chan int,10)var a string func f() {        a = "hello, world"        c } func main() {        go f()

2017-03-30 10:57:25 926

原创 Golang内存模型解析-1

Golang内存模型

2017-03-30 10:39:59 653

原创 Spring Boot新建项目的几个坑

有几个要注意的点:1,POM需要spring-boot-starter-data-jpa和mysql-connector-java,前者负责ORM相关类库,后者负责提供连接驱动。缺一不可2,DataSourceAutoConfiguration需要exclude,如果定义了dataSource bean的话。否则,需要配置application.property.如果允许AutoConfi

2017-03-20 16:43:37 684

原创 [Lintcode]Interval Sum II区间求和 II

Given an integer array in the construct method, implement two methods query(start, end) and modify(index, value):For query(start, end), return the sum from index start to index end in the given

2017-02-09 14:24:05 565

原创 [Lintcode]Maximum Subarray III最大子数组 III

Given an array of integers and a number k, find k non-overlapping subarrays which have the largest sum.The number in each subarray should be contiguous.Return the largest sum.ExampleGi

2017-02-08 14:21:49 1451

原创 *[Lintcode]带环链表 II

给定一个链表,如果链表中存在环,则返回到链表中环的起始节点的值,如果没有环,返回null。样例给出 -21->10->4->5, tail connects to node index 1,返回10分析:快慢指针。如果快指针为null,则无环。否则,快慢指针一定会在环上某点相遇。此时将快指针重置到起点并且和之前的慢指针一起同步移动,每次均移动一步直到相遇,相遇的点即为环的起点.

2017-02-07 11:40:12 554

原创 [Lintcode]Valid Number有效数字

xample"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true实现题。注意几个特例即可。如.1=true  1.=true e1=false 1e=falsepublic class Solution { /** * @

2017-01-22 18:09:22 462

原创 [Lintcode]Binary Search Tree Iterator

ExampleFor the following binary search tree, in-order traversal by using iterator is [1, 6, 10, 11, 12] 10 / \1 11 \ \ 6 12分析:考察非递归中序遍历二叉树。使用一个stack即可。复杂度满足O(h).

2017-01-19 11:09:36 267

原创 [Lintcode]String to Integer II

Example"10" => 10"-1" => -1"123123123123123" => 2147483647"1.0" => 1分析:直接实现。注意空格,正负号。public class Solution { /** * @param str: A string * @return An integer */ pu

2017-01-18 10:56:23 491

原创 *[Lintcode]Median of two Sorted Arrays

ExampleGiven A=[1,2,3,4,5,6] and B=[2,3,4,5], the median is 3.5.Given A=[1,2,3] and B=[4,5], the median is 3.分析:类似merge sort。class Solution { /** * @param A: An integer array.

2017-01-17 15:16:45 208

原创 **[Lintcode]Best Time to Buy and Sell Stock IV 买卖股票的最佳时机 IV Leetcode

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 at most ktransactions.ExampleGiven p

2017-01-17 11:02:11 301

原创 ***[Lintcode]最大矩形

类似于蓄水池问题,首先创造一个矩形,记录每一列上true的数量。[ [1, 1, 0, 0, 1], [0, 1, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 0, 1]]可转换为:[ [1, 1, 0, 0, 1], [0, 2, 0, 0, 2], [0, 0, 1, 1,

2017-01-15 19:07:08 709

原创 TOSCA简介

目前提到物联网,就会联想到IoT,CDN,TOSCA,NFV等。这些中,TOSCA作为开放云的标准,被广泛使用。TOSCA的目标如下: 即TOSCA用来定义云应用之前的交互及体系,包括组件,组件间的关系/依赖,及其需求及容量。从而允许跨云平台的自动化管理以及迁移。TOSCA的几大标准是:1)快速准确的发布应用至云提供商。2)快速适应变化3)云供应商由用户自由选择。

2016-12-27 18:05:06 7992 1

原创 **[Lintcode]Permutation Index II排列序号II

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.ExampleGiven

2016-12-07 22:37:24 839

原创 **[Lintcode]Ugly Number II 丑数 II

Ugly number is a number that only have factors 2, 3 and 5.Design an algorithm to find the nth ugly number. The first 10 ugly numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12...分析:(1) 1×2, 2×2,

2016-12-04 17:27:41 608

原创 *[Lintcode]Wiggle Sort摆动排序

Given an unsorted array nums, reorder it in-place such thatnums[0] = nums[2] ExampleGiven nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, 4].分析:之前想的是可以先排序, 然后使用双指针,每一次从

2016-12-04 10:55:08 231

原创 [Lintcode]Minimum Size Subarray Sum 和大于S的最小子数组

Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return -1 instead.ExampleGiven the array [2,3,1,

2016-11-27 18:00:37 274

原创 [Lintcode]Maximum Subarray II 最大子数组 II

Given an array of integers, find two non-overlapping subarrays which have the largest sum.The number in each subarray should be contiguous.Return the largest sum.ExampleFor given [1, 3, -1,

2016-11-27 16:23:02 353

原创 ***[Lintcode]Maximum Subarray Difference 最大子数组差

Given an array with integers.Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is the largest.Return the largest difference.ExampleFor [1, 2, -3, 1], return 6.分

2016-11-27 15:55:28 351

原创 **[Lintcode]Maximal Square 最大正方形

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.ExampleFor example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11

2016-11-27 10:21:08 346

原创 [Lintcode]Binary Tree Level Order Traversal II 二叉树的层次遍历 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).ExampleGiven binary tree {3,9,20,#,#,15,7},

2016-11-23 22:45:27 446

原创 *[Lintcode]k Sum II

Given n unique integers, number k (1Find all possible k integers where their sum is target.ExampleGiven [1,2,3,4], k = 2, target = 5. Return:[ [1,4], [2,3]]分析:递归

2016-11-20 18:11:48 249

JSP试题 含答案

JSP考试试题 包含答案 想要的赶紧下啊

2009-06-08

空空如也

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

TA关注的人

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