自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

AixsCode

知道怎么用是一回事,深入理解又是另一回事了

  • 博客(90)
  • 收藏
  • 关注

原创 Java实现之校验码

public class ValidateCode { // 图片的宽度。 private int width = 160; // 图片的高度。 private int height = 40; // 验证码字符个数 private int codeCount = 5; // 验证码干扰线数 private int lineCount = 150; // 验证码 privat...

2019-04-25 11:53:37 984

原创 消息队列Kafka和Rabbitmq的对比

不同的消息中间件的有不同的适应场景 对于Kafka和Rabbitmq来说在不同的场景下可按照以下的功能点进行划分:1. 优先级队列: 对于存在于队列中的消息,优先级高的消息具有被优先被消费的特权。这种情况有一种限制就是:消费者的消费速度要慢于生成者速度。2. 延迟队列:延迟队列存储的是对应的延迟消息,适用的场景就是:生产者在生产消息后,并不想让消费之直接拿到消息,而是等待一段时间再去消费。...

2019-04-15 11:51:27 7347 1

原创 kafka在windows环境下的搭建和使用

1. 首先下载kafka (这里是下载连接:https://www.apache.org/dyn/closer.cgi?path=/kafka/2.2.0/kafka_2.11-2.2.0.tgz) 注意到一点就是:kafaka下载时要下载二进制文件版本(binary)2. 新版本kafka内置了 zookeeper ,所有下载后解压后,不用配置。3. 进入目录下面直接启动就好...

2019-04-14 15:04:16 1032 1

原创 1084 Broken Keyboard (20 分)

On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to...

2019-03-05 16:45:37 330

原创 1108 Finding Average (20 分)

The basic task is simple: givenNreal numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. Alegalinput is a real...

2019-03-05 15:19:46 231

原创 1112 Stucked Keyboard (20 分)

On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen forktimes.Now given a result...

2019-03-05 11:19:53 142

原创 1105 Spiral Matrix (25 分)

1105Spiral Matrix(25 分)This time your job is to fill a sequence ofNpositive integers into aspiral matrixin non-increasing order. A spiral matrix is filled in from the first element at the uppe...

2019-03-04 17:03:52 116

原创 1052 Linked List Sorting (25 分)

A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integerkeyand aNextpointer to the next structure. Now give...

2019-03-04 15:58:35 139

原创 1012 The Best Rank (25 分)

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only:C- C Programming Language,M- Mathematics (Calculus or Linear Algrbra), andE- Eng...

2019-03-04 14:33:59 152

原创 1128 N Queens Puzzle (20 分)

The "eight queens puzzle" is the problem of placing eight chess queens on an8×8chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, ...

2019-03-04 13:19:19 124

原创 1024 Palindromic Number (25 分)

A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...

2019-03-04 11:24:47 173

原创 1107 Social Clusters (30 分)

When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. Asocial clusteris a set of people who have some of thei...

2019-03-03 14:26:49 217

原创 1053 Path of Equal Weight (30 分)

Given a non-empty tree with rootR, and with weightW​i​​assigned to each tree nodeT​i​​. Theweight of a path fromRtoLis defined to be the sum of the weights of all the nodes along the path fro...

2019-03-02 14:23:45 149

原创 1106 Lowest Price in Supply Chain (25 分)

1106Lowest Price in Supply Chain(25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Start...

2019-03-02 10:50:44 154

原创 1094 The Largest Generation (25 分)

A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input ...

2019-03-02 10:33:23 496 1

原创 1009 Product of Polynomials (25 分)

This time, you are supposed to findA×BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...

2019-03-01 16:27:54 108

原创 C++基础知识字符串、整型相互转化

1. C++11支持的特性 由string 转int 类型 通过stoi()函数 除此之位还有stol stod 分别是转化为long、double类型。 由int 转string类型,只需要to_string()就可以。2.(手写转换方法)string 转intint stringtoint(string s1){ int res=0; in...

2019-03-01 13:31:12 136

原创 1136 A Delayed Palindrome (20 分)

Consider a positive integerNwritten in standard notation withk+1digitsa​i​​asa​k​​⋯a​1​​a​0​​with0≤a​i​​<10for allianda​k​​>0. ThenNispalindromicif and only ifa​i​​=a​k−i​​for...

2019-03-01 12:48:36 135

原创 1021 Deepest Root (25 分)

A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root ...

2019-02-27 15:10:40 109

原创 1013 Battle Over Cities (25 分)

It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we nee...

2019-02-27 11:19:43 165

原创 1010 Radix (25 分)

Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive inte...

2019-02-23 17:38:30 218

原创 1070 Mooncake (25 分)

Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now ...

2019-02-22 22:40:30 211

原创 网易校招算法之独立的小易

题目描述小易为了向他的父母表现他已经长大独立了,他决定搬出去自己居住一段时间。一个人生活增加了许多花费: 小易每天必须吃一个水果并且需要每天支付x元的房屋租金。当前小易手中已经有f个水果和d元钱,小易也能去商店购买一些水果,商店每个水果售卖p元。小易为了表现他独立生活的能力,希望能独立生活的时间越长越好,小易希望你来帮他计算一下他最多能独立生活多少天。输入描述:输入包括一行,四个整数...

2019-01-31 17:39:49 134

原创 OOP原则在实际场景中的分析

 1.以开关原则为(open-close)为例(来源于杨晓峰大佬的实例)public class VIPCenter{ void serviceVIP(T extend User user) { if(user instance SlumDogVIP) { //穷 x VIP 活动抢的那种 ...

2019-01-31 16:38:45 296

原创 网易校招算法操作序列

题目描述小易有一个长度为n的整数序列,a_1,...,a_n。然后考虑在一个空序列b上进行n次以下操作:1、将a_i放入b序列的末尾2、逆置b序列小易需要你计算输出操作n次之后的b序列。输入描述:输入包括两行,第一行包括一个整数n(2 ≤ n ≤ 2*10^5),即序列的长度。第二行包括n个整数a_i(1 ≤ a_i ≤ 10^9),即序列a中的每个整数,以空格分割。输出...

2019-01-29 21:02:21 155

原创 网易校招算法题交错01串

题目描述如果一个01串任意两个相邻位置的字符都是不一样的,我们就叫这个01串为交错01串。例如: "1","10101","0101010"都是交错01串。小易现在有一个01串s,小易想找出一个最长的连续子串,并且这个子串是一个交错01串。小易需要你帮帮忙求出最长的这样的子串的长度是多少。输入描述:输入包括字符串s,s的长度length(1 ≤ length ≤ 50),字符串中只...

2019-01-29 20:20:57 339

原创 拼多多校招算法题迷宫寻路

题目描述假设一个探险家被困在了地底的迷宫之中,要从当前位置开始找到一条通往迷宫出口的路径。迷宫可以用一个二维矩阵组成,有的部分是墙,有的部分是路。迷宫之中有的路上还有门,每扇门都在迷宫的某个地方有与之匹配的钥匙,只有先拿到钥匙才能打开门。请设计一个算法,帮助探险家找到脱困的最短路径。如前所述,迷宫是通过一个二维矩阵表示的,每个元素的值的含义如下 0-墙,1-路,2-探险家的起始位置,3-迷宫的...

2019-01-28 17:17:46 743

原创 拼多多【六一儿童节】

题目描述六一儿童节,老师带了很多好吃的巧克力到幼儿园。每块巧克力j的重量为w[j],对于每个小朋友i,当他分到的巧克力大小达到h[i] (即w[j]>=h[i]),他才会上去表演节目。老师的目标是将巧克力分发给孩子们,使得最多的小孩上台表演。可以保证每个w[i]> 0且不能将多块巧克力分给一个孩子或将一块分给多个孩子。输入描述:第一行:n,表示h数组元素个数 第二行:n...

2019-01-24 12:06:18 371

原创 拼多多【最大乘积】

题目描述给定一个无序数组,包含正数、负数和0,要求从中找出3个数的乘积,使得乘积最大,要求时间复杂度:O(n),空间复杂度:O(1)输入描述:无序整数数组A[n]输出描述:满足条件的最大乘积示例1输入3 4 1 2输出24 思路:设置两个vector max min  ; max 维护输入的三个最大值,min 维护输入的2个最小值,最后比较三...

2019-01-23 13:05:44 267

原创 拼多多【大整数相乘】

题目描述有两个用字符串表示的非常大的大整数,算出他们的乘积,也是用字符串表示。不能用系统自带的大整数类型。输入描述:空格分隔的两个字符串,代表输入的两个大整数输出描述:输入的乘积,用字符串表示示例1输入72106547548473106236 982161082972751393输出7082024482963453804084865646610598...

2019-01-23 12:35:56 265

原创 Java深入理解之HashMap

Java数据结构的映射定义了一个接口java.util.Map,此接口有四个常用实现类,分别为HashMap、Hashtable、LinkedHashMap、TreeMap HashMap: 它根据键的hashcode值存储数据,大多数情况下可以直接定位到它的位置,但是遍历顺序不一致,HashMap最多只允许一条记录的键为null,允许多条记录的值为null,HashMap非线程安全,可能...

2019-01-16 10:51:19 251

原创 Java深入理解之泛型

1.Java中的泛型是什么?使用泛型的好处在集合中存储对象并在使用前进行类型转换不方便,泛型为了防止这种情况发生,它提供了编译期的类型安全,确保你只要把正确类型的对象放入集合中,避免了在运行时出现ClassCastException2.Java的泛型是如何工作的?什么是类型擦除?泛型是通过类型擦除来实现的,编译器在编译时擦除了所有类型相关的信息,所以在运行时不存在任何类型相关的信息,例...

2019-01-15 11:12:48 422

原创 Java深入理解之反射

每一个类都有一个class对象,包含了与类有关的信息,当编译一个新类时,会产生一个同名的.class文件,该文件内容保持着class对象。简而言之,通过反射,我们可以在运行时获得程序或程序集中每一个类型的成员和成员的信息。程序中一般的对象的类型都是在编译期就确定下来的,而 Java 反射机制可以动态地创建对象并调用其属性,这样的对象的类型在编译期是未知的。所以我们可以通过反射机制直接创建对象,...

2019-01-15 10:41:06 240

原创 Java深入理解之关键字

final1.数据声明数据为常量,可以是编译时常量,也可以是在运行时被初始化后不能被改变的常量对于基本类型,final使数值不变 对于引用类型,final 使引用不变,也就不能引用其它对象,但是被引用的对象本身是可以修改的。2.方法声明方法不能被子类重写。private 方法隐式地被指定为 final,如果在子类中定义的方法和基类中的一个 private 方法签名相同,此时...

2019-01-15 10:04:02 209

原创 Java深入理解之Object.clone()

1.cloneableclone() 是 Object 的 protected 方法,它不是 public,一个类不显式去重写 clone(),其它类就不能直接去调用该类实例的 clone() 方法。重写 clone() 得到以下实现:public class CloneExample { private int a; private int b; @Ove...

2019-01-14 18:41:38 350

原创 Java 深入理解之override和overload

1.重写(Override)存在于继承体系中,指子类实现了一个与父类在方法声明上完全相同的一个方法,为了满足里氏替换原则,重写有以下两个限制:子类方法的访问权限必须大于等于父类方法 子类方法的返回类型必须市父类方法返回类型或者其子类型使用@Override注解,可以让编译器帮忙检查是否满足上面的两个限制条件2.重载(Overload)存在于同一个类中,指一个方法与已经存在的方法...

2019-01-14 18:18:45 438

原创 Magic Coupon (25)

Magic Coupon (25)时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning tha...

2018-05-18 11:09:03 230

原创 Median (25)

Median (25)时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the medi...

2018-05-17 23:21:34 214

原创 Boys vs Girls (25)

Boys vs Girls (25)时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 This time you are asked to tell the difference between the lowest grade of all the male students and the highe...

2018-05-15 23:36:33 382

原创 Password (20)

Password (20)时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there ...

2018-05-15 23:32:10 261

空空如也

空空如也

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

TA关注的人

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