- 博客(18)
- 资源 (1)
- 收藏
- 关注
原创 pyspark union按位置合并而不是按列的名字合并
pyspark union 将A和B按照列的位置合并而不是列名合并,可能列名不对齐。先select()将列整理成相同顺序
2020-11-10 16:29:38
748
原创 leetcode 1346. Check If N and Its Double Exist 排序,双指针扫描,注意正负;哈希表
leetcode 1346. Check If N and Its Double Exist如果都是非负数的从小到大有序序列,从左往右i,j两个指针扫描,j为不满足2*a[i]<a[j]的下一个j。排序O(nlogn),扫描O(n)如果有正有负,分成两个序列,把负数序列反转、取相反数。class Solution {public: bool check_sorted(vector<int>& arr) {// sort(arr.begin(),arr.end()
2020-09-05 16:54:25
201
原创 leetcode 313. Super Ugly Number
313. Super Ugly Number遍历从小到大找ugly number,每个新的ugly number是primes中的素数乘积,必然是某个素数乘之前的某个ugly number。每个primes中的素数记录一个下标,对应将要乘的ugly number。每个primes中的素数,乘以之前的尽量小的ugly number,但如果之前某个ugly number能和该素数生成之前某个ugly number,则给该素数记录的接下来将要乘的ugly number下标+1。注意INT_MAX和long
2020-09-01 00:15:12
241
原创 leetcode 714. Best Time to Buy and Sell Stock with Transaction Fee 遍历、递推、状态转移
leetcode 714. Best Time to Buy and Sell Stock with Transaction Fee(未完待续)一开始的想法:遍历,低买高卖,考虑手续费,所以价差不超过手续费不卖,先跌后涨但跌幅不超过手续费不卖,示例正确但Wrong Answer。class Solution {public: int maxProfit(vector<int>& prices, int fee) { int len=prices.
2020-08-29 22:13:38
126
原创 leetcode 1171. Remove Zero Sum Consecutive Nodes from Linked List 前缀和
leetcode 1171. Remove Zero Sum Consecutive Nodes from Linked List/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullp
2020-08-28 00:11:20
147
原创 leetcode 189. Rotate Array
leetcode 189. Rotate Array调库:class Solution {public: void rotate(vector<int>& nums, int k) { int len=nums.size(); k=k%len; vector<int> vec_a(nums.end()-k,nums.end()); vector<int> vec_b(nums
2020-08-26 22:37:29
100
原创 洛谷 P1309 瑞士轮 归并
洛谷 P1309 瑞士轮https://www.luogu.com.cn/problem/P1309每一轮快排,超时:# include<iostream># include<fstream># include<vector> # include<algorithm> using namespace std;class Athlete{public: int id,competence,score; Athlete(){} //
2020-08-26 19:47:39
164
原创 UnboundLocalError: local variable ‘logs‘ referenced before assignment
UnboundLocalError: local variable ‘logs’ referenced before assignmenttensorflow model.fit(feature,label)UnboundLocalError: local variable ‘logs’ referenced before assignment训练集数据过小,增加数据即可详见https://github.com/tensorflow/tensorflow/issues/38064...
2020-08-24 17:20:42
2838
1
原创 MySQL向表中导入csv文件
mySQL向表中导入csv文件LOAD DATA LOCAL INFILE “data.csv”INTO TABLE my_tableFIELDS TERMINATED BY ‘,’ENCLOSED BY ‘"’LINES TERMINATED BY ‘\r\n’IGNORE 1 LINES;(此处忽略1行及表头)
2020-08-20 15:52:47
205
原创 conda设置proxy_server
conda config --set proxy_servers.http http://id:pw@address:portconda config --set proxy_servers.https https://id:pw@address:port
2020-07-23 17:38:13
2108
原创 matplotlib在linux服务器画图
matplotlib在linux服务器画图import matplotlibmatplotlib.use('Agg')import matplotlib.pyplot as plt注意语句顺序,use(‘Agg’)在plt之前
2020-07-23 15:41:52
400
原创 tensorflow LSTM stateless改为stateful
tensorflow LSTM stateless改为stateful训练模型时用stateless,预测时用stateful保持记忆。预测时新建模型,复制训练模型的参数。for nb, layer in enumerate(model.layers): model2.layers[nb].set_weights(layer.get_weights())...
2020-07-23 11:45:47
263
原创 pandas画双柱形图
pandas画双柱形图matplotlib画双柱形图需要指定两个柱形图subplot的位置使得恰好拼成一个双柱形图。用pandas画双柱形图更简便。import numpy as npimport pandas as pdimport matplotlib.pyplot as pltname_list=["A","B","C"]pair_list=[[1,1],[2,3],[4,5]]pair_list=np.array(pair_list)img_df=pd.DataFrame(pai
2020-05-16 17:04:42
2985
原创 Latex beamer ppt 中文
Latex beamer ppt 中文\documentclass{beamer}\usepackage[UTF8]{ctex}\usepackage{ulem}\usepackage{amsmath}\usepackage{amssymb}\usepackage{geometry}\usepackage{graphicx}\usepackage{subfigure}\usepa...
2020-05-07 11:20:49
2888
2
原创 Vim简单操作 命令模式 输入模式 保存 翻页 光标移动
Vim简单操作 命令模式 输入模式 保存 翻页 光标移动命令模式按i进入输入模式输入模式按esc进入命令模式命令模式h 或 向左箭头键(←) 光标向左移动一个字符j 或 向下箭头键(↓) 光标向下移动一个字符k 或 向上箭头键(↑) 光标向上移动一个字符l 或 向右箭头键(→) 光标向右移动一个字符组合键:10j即向下移动10个字符[Ctrl] + [f] 屏幕向下移动一页[...
2020-04-26 07:46:17
214
原创 洛谷 P1896 [SCOI2005]互不侵犯 递推/动归 (可状态压缩)
洛谷 P1896 [SCOI2005]互不侵犯题目描述在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案。国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子。输入格式只有一行,包含两个数N,K ( 1 <=N <=9, 0 <= K <= N * N)输出格式所得的方案数递推/动态规划只考虑一行,一行合法状态必须...
2020-04-19 00:06:03
203
原创 leetcode 1371. Find the Longest Substring Containing Vowels in Even Counts
Find the Longest Substring Containing Vowels in Even Counts用state表示[0,i]子字符串的状态,状态有5个二进制位,对应5个元音字母的奇偶性class Solution {public: int findTheLongestSubstring(string s) { int str_len...
2020-04-16 16:20:54
176
database_project.rar
2020-04-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人