split空字符串参数和不传参数的区别

今天写一个反转字符串的函数,如下: function reverseString(str) { var arr = str.split(); var arrNew = arr.reverse(); var strNew = arrNew.join(); return strNew; } reverseString("hello"); 用hello测试时,发现它并没有实现反转,原因是函数第一句代码并没有将hello字符串变成预期的样子,即
分类: 编程语言 发布时间: 03-31 22:32 阅读次数: 0

HDU 2159 FATE(二维背包)

Problem Description 最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s只怪。请问他能升掉这最后一级吗? Input 输入数据有多组,对于每组数据第一行输入n,m,k,s(
分类: 编程语言 发布时间: 03-31 22:32 阅读次数: 0

异常控制流&虚拟内存学习总结

异常控制流(Exceptional Contrl Flow, ECF) 概念: ECF: 现代系统通过使控制流发生突变,用来响应处理器状态中的某些变化。 异常的类别: 中断 异步发生,来自外部IO设备。、 系统调用 用户程序调用内核接口。 故障 缺页异常。 终止 进程 抽象 = 独立CPU + 独立内存。 用户态、内核态。 切换到内核态一般就是中断、系统调用咯。 上下文切换 主要切换: CPU相关 + 内存相关 + 进程相关。 CPU相关 = 寄存器 内存相关 = 页表 进程相关 = 进程表
分类: 编程语言 发布时间: 03-31 22:32 阅读次数: 0

第三集 Spring for Apache Kafka 接受消息

我们可以接受消息通过配置一个MessageListenerContainer 和提供一个消息监听或者通过使用@KafkaListener 注解 3.1 Message Listeners 当我们使用一个消息监听容器的时候,我们必须提供一个监听来接受数据。 当前有八种支持消息监听的接口,以下是这些接口列表: public interface MessageListener<K, V> { void onMessage(ConsumerRecord<K, V> data); } 使
分类: 编程语言 发布时间: 03-31 22:31 阅读次数: 0

【解题报告】 POJ - 3159 Candies(差分约束、最短路)

原题地址 其实这个题目思考起来和实现起来并不难 ,但是为了码一下发现的dalao的博客,还是写一下题解 dalao博客: 夜深人静写算法(四) - 差分约束 真的写的非常好啊!可以说是帮我又把最短路和建图的知识复习了一遍,吹爆dalao,简单的逛了一下,他其他的文章包括dp、线段树、树状数组等等都写的非常认真非常仔细,还附题集,每一题还点出了重点是什么,可以说是非常良心了!决定了,以后就跟着这个dalao混了! 思路 首先,差分约束这个东西听起来很高深,但实际上逻辑非常友好,处理一组不等式,求
分类: 编程语言 发布时间: 03-31 22:31 阅读次数: 0

.Net中泛型的来龙去脉

可以参考以下几篇文章: https://www.cnblogs.com/dotnet261010/p/9034594.html https://www.cnblogs.com/woaixiaozhi/p/5137658.html https://www.cnblogs.com/yilezhu/p/10029782.html https://blog.csdn.net/rise51/article/details/6153175
分类: 编程语言 发布时间: 03-31 22:30 阅读次数: 0

(Week 11)Python-Numpy_exercises

import numpy as np from scipy.linalg import toeplitz A = np.random.normal(0,1,size=(200,500)) B = toeplitz(np.random.random((500)),np.random.random((500))) [[-1.08139799 1.63626865 -1.19375553 ... 0.54016655 1.04225555 -0.13933849] [-0.8328577
分类: 其他 发布时间: 03-31 22:30 阅读次数: 0

(Week 12)Python-Matplotlib_exercises

Exercise 11.1: Plotting a function Plot the function y=sin2(x−2)e−x2 y=sin2(x−2)e−x2 over the interval [0, 2]. Add proper axis labels, a title, etc. 编写代码如下: import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set(color_codes
分类: 其他 发布时间: 03-31 22:30 阅读次数: 0

(Week 13)Python-Scipy_exercises

Exercise 10.1: Least squares Generate matrix A∈Rm×n A∈Rm×n with m>n m>n . Also generate some vector b∈Rm b∈Rm . Now find x=argminx||Ax−b||2 x=argminx||Ax−b||2 . Print the norm of the residual. 编写代码如下,调用lstsq函数求最小二乘解,再调用norm求范数即可(默认为2-范数)。 import scip
分类: 其他 发布时间: 03-31 22:30 阅读次数: 0

(Week 14)Python-pandas_exercises

cme193-ipython-notebooks-lecture 本次习题为【CME 193】中的练习,原题目及对应库的介绍见 cme193-ipython-notebooks-lecture Part 0 获取数据集 import pandas as pd anascombe = pd.read_csv('anscombe.csv') anascombe.head() dataset x y 0 I 10.0 1 I 8.0 2 I 13.0 3 I 9.0 4 I 11.0 Part 1
分类: 其他 发布时间: 03-31 22:29 阅读次数: 0

(Week 14)Python-sklearn_exercises

Exercise - sklearn exercise Create a classification dataset(n_samples>=1000, n_features>=10) Split the dataset using 10-fold cross validation Train the algorithms GaussianNB SVC(possible C values[1e-02, 1e-01, 1e00, 1e01, 1e02], RBF kernel) RandomFo
分类: 其他 发布时间: 03-31 22:29 阅读次数: 0

53. Maximum Subarray && 229. Majority Element II

53. Maximum Subarray Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest
分类: 其他 发布时间: 03-31 22:29 阅读次数: 0

212. Word Search II && 215. Kth Largest Element in an Array

212. Word Search II Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighbor
分类: 其他 发布时间: 03-31 22:29 阅读次数: 0

222. Count Complete Tree Nodes && 710. Random Pick with Blacklist

222. Count Complete Tree Nodes Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, and all nodes i
分类: 其他 发布时间: 03-31 22:28 阅读次数: 0

4. Median of Two Sorted Arrays && 23. Merge k Sorted Lists

4. Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both
分类: 其他 发布时间: 03-31 22:28 阅读次数: 0

java中的垃圾回收机制简介

内存空间是有限的,运行时如果不能获取到内存,会抛出OutOfMemory,一种有效的解决措施是,抛弃那些程序永远不会不再用到的对象,腾出空间。 如何定义对象不会用到 给对象添加一个引用计数器,每当这个对象被引用一次就加1,每当这个对象的引用失效1次,就减1
分类: 编程语言 发布时间: 03-31 22:28 阅读次数: 0

218. The Skyline Problem && 241. Different Ways to Add Parentheses

218. The Skyline Problem A city’s skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on a cityscape ph
分类: 其他 发布时间: 03-31 22:28 阅读次数: 0

使用小企鹅五笔单字输入模式

出于保护视力的需要,我在学习与工作中使用五笔输入法来盲打中文,从而可以有效地减少眼睛看屏幕的时间。例如,我每周将手写日记整理到电脑上的时候,一般都是只看着平时随身携带的日记本,一气呵成地将一段文字录入完毕后再统一核对、修改。为了减少盲打时的重码率,我都是将输入法自带的词库禁用,只使用单字输入模式。这样一来,就可以基本保证盲打出的每一个字就是我想要的那个。单字输入模式在Linux下的iBus输入法中已有支持。不过,iBus尚有一个致命的缺陷就是它的第一个候选条目总是被一个黑色块遮挡,非常影响用户
分类: 其他 发布时间: 03-31 22:28 阅读次数: 0

JavaScript中call、apply、bind的简单实现

先实现个call call:可以指定函数运行时的this。与apply之间的区别是传参方式不同,call的参数是若干参数列表,apply接受的是一个包含多个参数的数组。 首先,我们先实现第一个功能,指定函数运行时的this: Function.prototype.fakeCall = function(obj) { // 在传入的 obj 上创建一个属性,将该属性指向调用的函数 obj.fn = this // 然后执行 fn,则会将调用的函数的 this 指向 obj
分类: 其他 发布时间: 03-31 22:28 阅读次数: 0

网站模仿——LOFTER个人主页

代码片段 码云链接:https://gitee.com/gulveig/codes/e7q95kub6clvxt2ydi84g83
分类: 其他 发布时间: 03-31 22:28 阅读次数: 0