- 博客(259)
- 收藏
- 关注
原创 61-65题 题解
61. Rotate List Given a list, rotate the list to the right by k places, where k is non-negative. Example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. //如果k大于链表长度时,应
2018-01-31 21:49:16
445
原创 56-60题 题解
56. Merge Intervals Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. //不明白排序函数为什么要写成静态的 /** *
2018-01-31 21:40:35
395
原创 51-55题 题解
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
2018-01-31 21:33:37
364
原创 46-50题 题解
46. Permutations Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1],
2018-01-31 21:26:41
326
原创 41-45题 题解
41. First Missing Positive Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run
2018-01-31 21:19:32
311
原创 36-40题 题解
36. Valid Sudoku Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'.
2018-01-31 21:13:22
275
原创 31-35题 题解
31. Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearran
2018-01-31 21:06:31
407
原创 26-30题 题解
26. Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space
2018-01-31 20:59:18
234
原创 21-25题 题解
21. Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: Input: 1->2
2018-01-31 20:48:33
281
原创 Leetcode- 16-20题 题解
16. 3Sum Closest Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each
2018-01-05 20:32:21
408
原创 Leetcode- 11-15题 题解
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 l
2018-01-04 21:49:56
228
原创 Leetcode- 06-10题 题解
6. ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibil
2018-01-03 10:17:00
345
原创 Leetcode- 1-5题 题解
最近开始刷Leetcode了,大三狗还没有找到实习,很菜啊,希望明年三月份能找份实习工作吧!2017年最后一篇博客,明天都元旦了,提前对大家说元旦快乐哈! 下面所有代码在我GitHub上也有,地址:https://github.com/zzuliLL/Leetcode- 1. Two Sum Given an array of integers, return indices o
2017-12-31 21:55:36
343
1
原创 牛客练习赛9 B 珂朵莉的值域连续段
题目链接:https://www.nowcoder.com/acm/contest/40/B 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 珂朵莉给你一个有根树,求有多少个子树满足其内部节点编号在值域上连续 一些数在值域上连续的意思即其在值
2017-12-30 11:12:07
345
原创 Python 3.xx socket编程 - 简单通讯软件 - Client/Server
最近自学的python基础,刚看了一些socket(套接字)编程,写了一个简单的通讯软件,分为客户端和服务器,在同一台主机或者两台不同的主机间的通信 代码: # Client import socket s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect(("172.20.204.130",8888)) # 目的服务器
2017-12-22 21:32:14
459
原创 Wannafly挑战赛4 C 割草机
题目链接:https://www.nowcoder.com/acm/contest/35/C 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 有一块n*m的地,每块地要么长满杂草(用'W'表示),要么是空地(用'G'表示),现在有一个人站在(1,1),面向
2017-11-25 10:22:30
510
原创 Wannafly挑战赛4 A 解方程
题目链接:https://www.nowcoder.com/acm/contest/35/A 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 给出n个整数和x,请问这n个整数中是否存在三个数a,b,c使得ax2+bx+c=0,数字可以重复使用。 输入描述:
2017-11-25 10:17:29
488
原创 牛客练习赛6 D 世界上最可爱的珂朵莉
题目链接:https://www.nowcoder.com/acm/contest/26/D 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 65536K,其他语言131072K 64bit IO Format: %lld 题目描述 我永远喜欢珂朵莉~! 有两个长为n的序列a[i]与b[i] 你可以把任意不多于x个a序列中的数变
2017-11-18 14:25:16
756
原创 牛客练习赛6 A 猴子吃香蕉(等差数列)
题目链接:https://www.nowcoder.com/acm/contest/26/A 题目描述 有n只猴子,第i只猴子每过xi小时会连续吃香蕉yi小时。猴子从第二次开始每次休息结束后这只猴子连续吃香蕉的时间会增加zi小时。 给定n只猴子,每一只的xi,yi,zi,以及时间t,求在前t小时中,所有猴子共吃了多少小时。 对于一只猴子来说是这样的: 从第1小时开始
2017-11-18 14:21:09
690
原创 hihocoder #1620 : 股票价格3
题目链接:http://hihocoder.com/problemset/problem/1620解析:维护一棵树,树根里面存(没有找到第一个大于该值的)最小值的编号,一直维护就好了,借鉴大佬得100分的代码代码:#include<stdio.h> #include<algorithm> #include<string.h> #include<queue> using namespace std;t
2017-11-05 17:43:50
321
原创 hihocoder #1619 : “共同富裕”
题目链接:http://hihocoder.com/problemset/problem/1619解析:看别人的代码才知道,最小步数应该是每一个数到达最小值的步数之和,小的变成大的,小的+1,变相就是大的-1代码:#include<stdio.h> #include<algorithm> #include<string.h> #include<queue> using namespace std;t
2017-11-05 17:39:14
1131
原创 Atcoder arc 084 D - Small Multiple(双向队列+抽屉原理)
题目链接:http://arc084.contest.atcoder.jp/tasks/arc084_b D - Small Multiple Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement Find the smallest possi
2017-11-05 17:33:36
968
原创 Atcoder arc 084 C - Snuke Festival(前缀和+二分)
题目链接:http://arc084.contest.atcoder.jp/tasks/arc084_a C - Snuke Festival Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement The season for Snuke Festival
2017-11-05 17:28:17
926
原创 hdu 6227 Rabbits
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6227 解析:给你n个位置,选其中一个往另外其它两个位置的中间插,问能插几次 代码:#include<bits/stdc++.h> using namespace std; typedef long long LL;int a[509], b[509];int main() { int t,
2017-11-05 17:15:30
745
原创 hdu 6225 Little Boxes
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6225 解析:求四个数的和,大整数加法 代码:import java.io.*; import java.math.BigInteger; import java.util.*;public class Main { public static Scanner s = new Scanner(
2017-11-05 17:11:43
889
原创 hdu 6222 Heron and His Triangle
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6222 解析:规律:a[n] = 4*a[n-1] - a[n-2] 代码:import java.io.*; import java.math.BigInteger; import java.util.*;public class Main { public static Scanner s
2017-11-05 17:09:13
1307
原创 Wannafly模拟赛5 D Aria(全排列)
题目链接:https://www.nowcoder.com/acm/contest/18/D时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 Aria是一名武侦高强袭科的学生,由于悬殊的实力差距,没有人可以 与她配合。所以正如她的名字一样(Aria在歌剧中有独唱曲之意),Aria一直
2017-11-05 17:02:21
360
原创 Wannafly挑战赛2 B Travel(dij)
题目链接:https://www.nowcoder.com/acm/contest/17/B 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 精灵王国有N座美丽的城市,它们以一个环形排列在Bzeroth的大陆上。其中第i座城市到第i+1座城市花
2017-10-28 16:25:55
764
原创 Wannafly模拟赛4 C Sum(树状数组)
题目链接:https://www.nowcoder.com/acm/contest/16/C 时间限制:1秒 空间限制:131072K 题目描述 考虑维护一个这样的问题: (1) 给出一个数组A,标号为1~n (2) 修改数组中的一个位置。 (3) 询问区间[l,r]中所有子集的位运算and之和mod(109+7)。 位运算and即为“pascal中的and”和“
2017-10-21 16:11:23
512
原创 Wannafly模拟赛4 D Fancy Signal Translate(字典树)
题目链接:https://www.nowcoder.com/acm/contest/16/D 时间限制:1秒 空间限制:131072K 题目描述 FST是一名可怜的小朋友,他很强,但是经常fst,所以rating一直低迷。 但是重点在于,他真的很强!他发明了一种奇特的加密方式,这种加密方式只有OIer才能破解。 这种加密方式是这样的:对于一个01串,他会构造另一个01
2017-10-21 11:56:33
414
原创 Wannafly模拟赛4 B Distance
题目链接:https://www.nowcoder.com/acm/contest/16/B 时间限制:1秒 空间限制:131072K 题目描述 FST作为小朋友,经常会遇到和距离有关的问题,但是他已经厌倦了曼哈顿距离和欧几里德距离,所以FST就定义了一种FST距离。 这种距离并不用于空间或平面中,而运用于FST发明的一些神奇的算法中(唔... ...)。 设i号元素
2017-10-21 11:52:31
376
原创 Wannafly模拟赛4 A Laptop (RMQ)
题目链接:https://www.nowcoder.com/acm/contest/16/A 时间限制:1秒 空间限制:131072K 题目描述 FST是一名可怜的小朋友,他很强,但是经常fst,所以rating一直低迷。 但是重点在于,他非常适合ACM!并在最近的区域赛中获得了不错的成绩。 拿到奖金后FST决定买一台新笔记本,但是FST发现,在价格能承受的范围内,笔
2017-10-21 11:46:40
442
原创 hdu 2586 How far away ? (LCA转RMQ)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2586 How far away ? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 18268 Accept
2017-10-15 15:42:04
347
原创 Wannafly挑战赛1 B Xorto
题目链接:https://www.nowcoder.com/acm/contest/15/B 题目描述 给定一个长度为n的整数数组,问有多少对互不重叠的非空区间,使得两个区间内的数的异或和为0。 输入描述: 第一行一个数n表示数组长度; 第二行n个整数表示数组; 1 输出描述: 一行一个整数表示答案。 示例1 输入 3 0 0 0 输出
2017-10-14 12:14:54
564
原创 Wannafly挑战赛1 A Treepath
题目链接:https://www.nowcoder.com/acm/contest/15/A 时间限制:1秒 空间限制:32768K 题目描述 给定一棵n个点的树,问其中有多少条长度为偶数的路径。路径的长度为经过的边的条数。x到y与y到x被视为同一条路径。路径的起点与终点不能相同。 输入描述: 第一行一个数n表示点的个数; 接下来n-1行,每行两个整数x,y表示边;
2017-10-14 12:10:05
393
原创 杜教模板(转载一篇cpp文件)
#include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) #define per(i,a,n) for (int i=n-1;i>=a;i--) #def
2017-10-13 16:58:50
856
原创 sql学习日志1
select create drop alter insert update delete grant revoke create schema __ drop schema __ 创建模式 create table __ drop table __ alter table 创建删除修改表 create view __ drop view 视图 crate index
2017-10-12 18:07:32
378
原创 hdu 5269 ZYB loves Xor I(字典树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5269 ZYB loves Xor I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1149 Accepted
2017-09-08 16:21:25
366
原创 51 NOD 1010 只包含因子2 3 5的数(暴力枚举)
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010 1010 只包含因子2 3 5的数 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 收藏 关注 K的因子中只包含2 3 5。满足条件的前10个数
2017-08-29 16:04:20
356
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人