自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

长镜头

学无止境

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

原创 Java清空某文件夹内的所有内容

注意如果待删除的是一个文件夹,就不能直接调用delete()删除。import java.io.File;public class DeleteDirTest { public static void main(String[] args) { String path = "G:\\temp"; deleteDir(path); } public static boole

2017-08-24 15:45:14 29298 2

原创 [leetcode]329. Longest Increasing Path in a Matrix

Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of the boundary (i.e. wrap-around is not allowed).我们需要找到一个

2017-08-24 15:17:57 293

原创 Java线程和锁的简单使用用法

Java实现线程有以下两种方法:1.实现Runnable接口这两种方法中,建议使用第一种实现Runnable接口的方法,因为:1)Java不支持多重继承,因此扩展Thread类就代表这个子类不能扩展其他类;2)继承整个Thread类的开销过大。

2017-07-20 16:13:41 683

原创 KMP算法的Java实现

输入第一行一个整数N,表示测试数据组数。接下来的N*2行,每两行表示一个测试数据。在每一个测试数据中,第一行为模式串,由不超过10^4个大写字母组成,第二行为原串,由不超过10^6个大写字母组成。其中N输出对于每一个测试数据,按照它们在输入中出现的顺序输出一行Ans,表示模式串在原串中出现的次数。import java.util.Scanner;

2017-07-15 18:14:08 309

转载 [leetcode]11. Container With Most Water

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0

2017-05-03 17:15:46 252

原创 【leetcode】8. String to Integer (atoi)

https://leetcode.com/problems/string-to-integer-atoi/#/description题目是将字符串转成整型数,但是需要考虑多种样例输入。根据多次尝试,总结如下:首先将字符串首尾空格全部去掉;然后取它中从头开始到第一个非法字符(除数字0到9之外的数)之前的串,可以确定的是这个串的形式应该是:+/-xxxx或者是xxx或者直接是+/-。如果是+/-,

2017-05-02 18:42:03 206

转载 求二进制数中1的个数

给定一个一个字节(8位)的无符号整型数,求它的二进制数表示中1的个数。分析:一个比较容易想到的方法是从低位到高位判断是否为1,每得到一位就把这个数右移,这样只需取最低位即可。时间复杂度是O(logv),其中logv是这个数的位数。如果还想进一步降低时间复杂度,我们可以只关注那些数位上为1的位。对于一个二进制数(比如11010000),我们可以这样找到它里面的1:把这个数减一(11010000

2017-04-22 01:31:13 212

转载 [leetcode]4. Median of Two Sorted Arrays

这个题是要求两个已排好序的数组合并之后的中位数,时间复杂度要为O(log(m+n))。

2017-04-02 21:18:59 223

转载 [leetcode]3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "

2017-03-31 00:07:16 179

转载 [编程题]暗黑的字符串

一个只包含'A'、'B'和'C'的字符串,如果存在某一段长度为3的连续子串中恰好'A'、'B'和'C'各有一个,那么这个字符串就是纯净的,否则这个字符串就是暗黑的。例如:BAACAACCBAAA 连续子串"CBA"中包含了'A','B','C'各一个,所以是纯净的字符串AABBCCAABB 不存在一个长度为3的连续子串包含'A','B','C',所以是暗黑的字符串你的任务就是计算出长度

2017-03-22 18:18:10 296

原创 [编程题]回文序列

如果一个数字序列逆置之后跟原序列是一样的就称这样的数字序列为回文序列。例如:{1, 2, 1}, {15, 78, 78, 15} , {112} 是回文序列, {1, 2, 2}, {15, 78, 87, 51} ,{112, 2, 11} 不是回文序列。现在给出一个数字序列,允许使用一种转换操作:选择任意两个相邻的数,然后从序列移除这两个数,并用这两个数字的和插入到这两个数之

2017-03-22 16:18:45 722

转载 [编程题]跳石板

小易来到了一条石板路前,每块石板上从1挨着编号为:1、2、3.......这条石板路要根据特殊的规则才能前进:对于小易当前所在的编号为K的石板,小易单次只能往前跳K的一个约数(不含1和K)步,即跳到K+X(X为K的一个非1和本身的约数)的位置。 小易当前处在编号为N的石板,他想跳到编号恰好为M的石板去,小易想知道最少需要跳跃几次可以到达。如果不能到达,输出-1。例如:N = 4,M

2017-03-22 15:37:01 584

转载 [leetcode]382. Linked List Random Node

Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.Follow up:What if the linked list is extremely large and i

2016-08-16 23:24:08 252

原创 [leetcode]347. Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number

2016-05-28 16:47:20 286

原创 chrome浏览器插件隐藏leetcode上了锁的题目

相信有不少人和我一样对leetcode上了锁的题目有些烦,于是写了一个简单的js插件用于将其隐藏。你可以下载附件后从chrome扩展程序中添加,即可达到隐藏的效果。文档下载请移步jsdemo.rar

2016-05-28 15:56:49 3617

原创 [leetcode]89. Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of

2016-05-17 16:48:00 322

转载 [leetcode]141. Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?转自https://leetcode.com/discuss/32906/o-1-space-solution方法:使用两个指针:slow和fast。它俩都

2016-05-07 21:26:06 322

原创 [leetcode]337. House Robber III

The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour

2016-05-06 22:26:40 279

原创 198. House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house

2016-04-28 17:04:49 235

转载 51. N-Queens

问题描述:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens

2016-04-24 16:18:40 251

转载 318. Maximum Product of Word Lengths

Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case le

2016-04-16 22:05:56 218

原创 319. Bulb Switcher

问题描述:There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or tur

2016-04-13 23:02:46 239

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

2016-04-12 23:43:02 219

原创 242. Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may a

2016-04-10 21:59:02 277

转载 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:Given

2016-04-09 17:03:20 423

原创 大数的存储问题,计算1~40所有数的阶乘

采用int数组存储每一位,模拟乘法操作,逐位相乘,往前进位。

2016-03-21 19:11:09 7294

转载 求图的顶点连通度和边连通度

思路:从网上找了一下大牛对于这类问题的总结:图的连通度问题是指:在图中删去部分元素(点或边),使得图中指定的两个点s和t不连通 (不存在从s到t的路径),求至少要删去几个元素。 图的连通度分为点连通度和边连通度: (1)点连通度:只许删点,求至少要删掉几个点(当然,s和t不能删去,这里保证原图中至少有三个点); (2)边连通度:只许删边,求至少要删掉几条边。 并且,

2016-03-18 15:59:42 8464

转载 后缀子串排序

题目描述:对于一个字符串,将其后缀子串进行排序,例如grain其子串有:grain rain ain in n然后对各子串按字典顺序排序,即: ain,grain,in,n,rain输入:每个案例为一行字符串。输出:将子串排序输出样例输入:grain样例输出:aingraininnrain#include #

2016-02-08 22:51:47 1833

原创 整除问题

题目描述:给定n,a求最大的k,使n!可以被a^k整除但不能被a^(k+1)整除。输入:两个整数n(2输出:一个整数.样例输入:6 10样例输出:1

2016-02-07 15:53:53 754

原创 设计一个二次方程计算器

题目描述:设计一个二次方程计算器输入:每个案例是关于x的一个二次方程表达式,为了简单,每个系数都是整数形式。输出:每个案例输出两个实数(由小到大输出,中间由空格隔开),保留两位小数;如果无解,则输出“No Solution”。样例输入:x^2+x=3x+4样例输出:-1.24 3.24注意要考虑系数是多位数字的情况。#include #incl

2016-02-05 12:03:59 742

转载 Java中ArrayList与LinkedList的区别

1.ArrayList是实现了基于动态数组的数据结构,LinkedList基于链表的数据结构。 2.对于随机访问get和set,ArrayList觉得优于LinkedList,因为LinkedList要移动指针。 3.对于新增和删除操作add和remove,LinedList比较占优势,因为ArrayList要移动数据。

2015-04-18 21:29:19 337

转载 进程与线程的区别

进程是一个具有独立功能的程序关于某个数据集合的一次运行活动。它可以申请和拥有系统资源,是一个动态的概念,是一个活动的实体。它不只是程序的代码,还包括当前的活动,通过程序计数器的值和处理寄存器的内容来表示。通常在一个进程中可以包含若干个线程,它们可以利用进程所拥有的资源。在引入线程的操作系统中,通常都是把进程作为分配资源的基本单位,而把线程作为独立运行和独立调度的基本单位。由于线程比进程更小,基本上

2015-04-18 20:42:39 220

chrome隐藏leetcode上锁题目js插件

chrome隐藏leetcode上锁题目js插件

2016-05-28

空空如也

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

TA关注的人

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