摘要: Q:Scrapy抓取的内容(包含中文)输出到JSON Lines文件时如何确保输出的是字符本身而不是其unicode编码? A:默认的JsonLinesItemExporter其ensure_ascii属性为True,使得在ASCII字符集中包含的字符才能输出字符本身,其他的字符(如各种东亚语言)则 阅读全文
posted @ 2018-08-06 22:14 HitAnyKey 阅读(851) 评论(0) 推荐(0) 编辑
摘要: 1. 线性归一化 x' = (x-min(x)) / (max(x)-min(x)) 适用于数值比较集中的情况,可使用经验值常量来来代替max,min 2. 标准差归一化 x'=(x-μ) / σ 经过处理后符合标准正态分布,即均值为0,标准差为1 3. 非线性归一化 使用非线性函数log、指数、正 阅读全文
posted @ 2017-11-13 10:50 HitAnyKey 阅读(2061) 评论(0) 推荐(0) 编辑
摘要: 问题: 来源:https://leetcode.com/problems/simplify-path Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home 阅读全文
posted @ 2017-11-13 09:23 HitAnyKey 阅读(298) 评论(0) 推荐(0) 编辑
摘要: 题目: 链接:https://www.nowcoder.com/questionTerminal/9ae56e5bdf4f480387df781671db5172来源:牛客网 我们有两个字符串m和n,如果它们的子串a和b内容相同,则称a和b是m和n的公共子序列。子串中的字符不一定在原字符串中连续。例 阅读全文
posted @ 2017-11-13 08:44 HitAnyKey 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 溢出,则和的最高位(即符号位)与两个加数都不相同,例如 1)非负数+非负数=负数 2)负数+负数=非负数 那么,假设x为a与b的和,((a^b)>=0 && (x^a)<0) 为真则溢出,^ 表示异或 阅读全文
posted @ 2017-11-12 21:07 HitAnyKey 阅读(1558) 评论(0) 推荐(0) 编辑
摘要: 题目: 天上掉馅饼 时间限制:C/C++语言 1000MS;其他语言 3000MS 内存限制:C/C++语言 131072KB;其他语言 655360KB 题目描述: 大家都知道“天上不会掉馅饼”这句话,但是有一天,小明在回学校的路上,天上还真掉起了馅饼。小明的人品实在有点好,这馅饼会掉在小明身边1 阅读全文
posted @ 2017-11-04 22:30 HitAnyKey 阅读(1992) 评论(0) 推荐(0) 编辑
摘要: 题目大意:给定整数n,求出1~n的全排列 示例 输入:n=3 输出:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1] 阅读全文
posted @ 2017-10-25 17:23 HitAnyKey 阅读(1357) 评论(0) 推荐(0) 编辑
摘要: 今天在编写Spark应用的时候,想把处理结果输出为JSON字符串,查到Java比较常用的JSON处理包gson,按照其API编写代码后运行程序,总是出现"NoSuchMethodException in Gson JsonArray"。 开始我以为是导入包的方式有问题,但查看出错位置发现,只有Jso 阅读全文
posted @ 2017-10-12 21:29 HitAnyKey 阅读(1867) 评论(0) 推荐(0) 编辑
摘要: 题目: 主机名由多级域名组成,自右向左,依次是顶级域名、二级域名、三级域名…..以此类推 例,主机名:google.com.hkhk是顶级域名 com是二级域名 google是三级域名 现在我们需要实现一个主机名的排序功能 排序规则 1)主机名按照域名等级排序,即先按照顶级域名排序,顶级域名相同的再 阅读全文
posted @ 2017-09-28 21:14 HitAnyKey 阅读(585) 评论(0) 推荐(0) 编辑
摘要: 堆排序 堆节点的访问 通常堆是通过一维数组来实现的。在数组起始位置为0的情形中: 父节点i的左子节点在位置(2*i+1); 父节点i的右子节点在位置(2*i+2); 子节点i的父节点在位置floor((i-1)/2); 堆的操作 在堆的数据结构中,堆中的最大值总是位于根节点(在优先队列中使用堆的话堆 阅读全文
posted @ 2017-09-25 09:57 HitAnyKey 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 冒泡排序(英语:Bubble Sort,台湾另外一种译名为:泡沫排序)是一种简单的排序算法。它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。这个算法的名字由来是因为越小的元素会经由交换慢慢“浮 阅读全文
posted @ 2017-09-23 21:18 HitAnyKey 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 来源:https://leetcode.com/problems/sort-list Sort a linked list in O(n log n) time using constant space complexity. 归并排序(Merge Sort,台湾译作:合并排序)是建立在归并操作上的 阅读全文
posted @ 2017-09-20 21:16 HitAnyKey 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 来源:https://leetcode.com/problems/sort-colors Given an array with n objects colored red, white or blue, sort them so that objects of the same color are 阅读全文
posted @ 2017-09-19 21:24 HitAnyKey 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 来源:https://leetcode.com/problems/insertion-sort-list Sort a linked list using insertion sort. 方法: 1. 使用一个preHead指向头节点,这样在将节点插入头节点前面时(即某个节点值比头节点小)不需要进行 阅读全文
posted @ 2017-09-19 20:49 HitAnyKey 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 来源:https://leetcode.com/problems/intersection-of-two-arrays Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1 阅读全文
posted @ 2017-09-19 10:35 HitAnyKey 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 来源:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal Java Python 阅读全文
posted @ 2017-09-17 16:10 HitAnyKey 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 先序遍历(Preorder Traversal) 根-左-右 1. 递归 Java 1 /** 2 * Definition for a binary tree node. 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * 阅读全文
posted @ 2017-09-17 11:19 HitAnyKey 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 来源:https://leetcode.com/problems/balanced-binary-tree Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced bin 阅读全文
posted @ 2017-09-16 21:48 HitAnyKey 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 来源:https://leetcode.com/problems/maximum-depth-of-binary-tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes al 阅读全文
posted @ 2017-09-16 10:44 HitAnyKey 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 来源:https://leetcode.com/problems/binary-tree-level-order-traversal Given a binary tree, return the level order traversal of its nodes' values. (ie, fr 阅读全文
posted @ 2017-09-15 10:26 HitAnyKey 阅读(311) 评论(0) 推荐(0) 编辑