自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(161)
  • 收藏
  • 关注

原创 leetcode刷题记录

Union Find:Friend Circles:Union Find. I used weighting and path compression.Hash:Longest Consecutive SequenceUse Hash (in python it is set) to quickly judge whether an element is in a set.DFS:Knight Probability in ChessboardDFS.

2020-09-07 10:48:56 347

原创 Pandas Numpy Advanced

【代码】Pandas Numpy Advanced。

2024-03-11 09:59:34 121

原创 C++ unique_ptr and shared_ptr

You can only call std::dynamic_pointer_cast on shared_ptr. For unique_ptr, you need to dynamic_cast its raw pointer and create a new unique_ptr with it and manully release the base pointer if the cast succeeds.std::move won’t temporarily increase refcoun

2024-02-28 10:02:22 152

原创 C++ Cast

Compile-Time Casts: static_cast, const_cast, and reinterpret_cast are primarily compile-time operations. They do not incur runtime overhead but require care to avoid undefined behavior or other issues.Runtime Casts: dynamic_cast involves runtime checks t

2024-02-20 09:38:11 247

原创 C++ move semantics

Other Tips: The explicit keyword is a valuable tool in C++ for controlling how constructors and conversion operators are invoked, preventing implicit conversions that can lead to subtle bugs or unintended behavior. By making conversions explicit, programme

2024-02-20 07:09:26 647

原创 python and c++ data structures and operations

c++ STL in Leetcode

2023-12-13 08:55:49 380

原创 C++ tricks of auto

【代码】C++ tricks of auto。

2023-03-21 04:38:14 84

原创 Python Leetcode Notes

Python Leetcode Notes

2022-11-16 05:39:02 85

原创 C++ leetcode note

c++ leetcode note

2022-11-12 05:49:28 237

原创 C++ iteration and reverse iteration

pt!

2022-10-28 10:39:03 339

原创 C++ initialization of vector

https://www.geeksforgeeks.org/initialize-a-vector-in-cpp-different-ways/Create a 2D vector of 5x3 matrix:vector dp (5, vector (3,0))

2022-10-25 11:58:54 892

原创 QuickSelect

QuickSelect AlgorithmTime complexity:(1) Kth largest number: https://stackoverflow.com/questions/5945193/average-runtime-of-quickselect/25796762(2) decrease by a fixed proportion by using median of mediansMedian of Median

2021-06-07 19:48:32 98

原创 new和init

https://www.cnblogs.com/shenxiaolin/p/9307496.html

2021-02-20 15:11:26 91

原创 GARCH model in python arch package

GARCH model in python arch packagefrom arch import arch_model

2021-01-28 09:09:45 224

原创 Binary indexed tree

Suitable for interval sum or prefix sum.Interval sum is just difference of two prefix sums.Compared with Segment Tree, Binary Indexed Tree requires less space and is easier to implement.BIT needs exactly n extra spaces, but Segment Tree needs approximat

2021-01-19 06:35:56 118

原创 Complete binary tree

Complete binary tree is a special kind of binary tree. It has all the nodes one by one. It does not need to be a full pyramid. Complete binary tree can be stored in an array, which is the main advantage of it. And the parent nodes and child nodes have rela

2021-01-19 06:12:19 166

原创 Segment tree

https://www.cnblogs.com/jason2003/p/9676729.html

2021-01-19 02:29:39 110

原创 Top k largest elements:Quick Select vs. Priority Queue

Quick select time complexity is O(n) on average no matter what k is.Priority Queue has time complexity O(nlog(k)).

2021-01-18 09:18:26 81

原创 how to change legend in pandas.df.plot()

You need to use y to specify the columns and then set labels.

2021-01-14 05:57:03 351 1

原创 Adding multiple strings in WHERE clause - SQL

SELECT name, population FROM world WHERE name IN ('france','Germany','Italy');

2021-01-12 09:40:39 82

原创 change column name when using pandas plot

fig, ax = plt.subplots(1,1) (r_p+1).cumprod().plot(ax=ax) (r_bench+1).cumprod().plot(ax=ax) ax.legend(["portfolio", "benchmark"])

2021-01-07 07:14:40 119

原创 pandas plot color

P_c_df.plot(ax=ax[i][0],style="^-", color=["red","green","purple","orange"])

2020-12-28 11:39:15 524

原创 color and type of plot line and dot

You can convey str directly for both color and line type and dot type. If you want to further change the dots’ color, you can set mec, mfc for the edge color and center color of dots separately.

2020-12-21 03:50:12 149

原创 markevery can control which dots to be plotted

2020-12-21 03:46:23 230

原创 plt.sca can control which subplot to apply plt methods

2020-12-21 03:33:04 321

原创 Avoid autocompleting of the dates in plot

2020-12-21 03:06:02 190

原创 Priority Queue and Heap in Python

Two kinds of priority queue implementation:from queue import PriorityQueueimport heapqHeapqVisit for details: https://docs.python.org/3/library/heapq.htmlHeapq functions are directly applied to list. You can create a normal list, can convey it int.

2020-12-16 16:06:09 117

原创 scipy.optimize.minimize

def fff(x1,x2,x3): return (x1[0]-x2)**2+(x1[1]-x3)**2 result = minimize(fff, [0,1], (1,2)) # x0可以是列表,但只对应相应函数的第一个位置,args必须是tuple,对应所有剩下位置。result.x # 参数拟合值

2020-12-13 14:31:27 302 1

原创 递归和循环

递归优点:逻辑清晰,容易理解,容易写。递归缺点:函数堆栈使用多,时间空间消耗大。循环优点:时间空间消耗小。循环缺点:逻辑复杂,难以理解,难写。尾递归和单向递归都可以写成循环,尤其是尾递归,最好是写成循环,而且也很容易写成循环,甚至可以通过机械的步骤来实现,不少编译器也实现了尾递归直接优化成循环的功能。python3.6未实现尾递归优化,最大递归调用深度是3000左右。...

2020-11-25 03:14:50 235

原创 python各种进制和十进制之间的相互转换

https://www.cnblogs.com/weiliwei-lucky/p/11201428.html

2020-11-24 13:28:52 270

转载 python多重继承问题

链接:https://www.cnblogs.com/miyauchi-renge/p/10923127.html

2020-11-11 03:54:47 66

原创 决策单调性

决策单调性定义与证明https://www.cnblogs.com/YSFAC/p/13363203.html详见此文。重点:考虑形如????????(????)=????????????{????????(????)+????(????,????)}的dp。(max类似)其中每一个j都称为一个决策点。定义:一个dp满足决策单调性的充要条件是:对于两个决策点????<????,若在i处y优于x,则在[????+1,????]处y都优于x。定理:若w满足四边形不等式,则dp满足决策单调性

2020-11-03 09:57:05 443

原创 单调队列

https://blog.csdn.net/qq_41021816/article/details/81428225

2020-11-03 04:34:42 82

原创 binary search package in python

import bisecta = [1,2,3,4]b = bisect.bisect_left(a,2.5)b # b = 2

2020-10-26 01:20:11 66

原创 Namedtuple

Name the constantsfrom collections import namedtupleGridState = namedtuple('GridState', 'start ending empty obstacle')grid_state = GridState( start = 1, ending = 2, empty = 0, obstacle = -1)

2020-10-25 09:26:53 59

原创 DFS framework

void dfs(){ if(到达中点状态) { ... //根据题意添加 return; } if(越界或不合法状态) return; if(特殊状态) // 剪枝 return; for(扩展方式) { if(扩张方式所到达状态合法) { 修改操作; // 根据题意添加 标记; dfs()

2020-10-25 08:21:32 55

原创 Union Find pros and cons

UF’s biggest pro is that it is convenient to add or delete connections. For example, in Knuth’s MST algorithm, you need to add black edges contiguously, so using UF is good.If you have a fixed shape of graph, DFS can be better than UF.

2020-10-22 02:42:52 82

原创 BFS in python

BFS需要一个marked来记录是否访问过该点,需要记录到达该点所需步数,需要一个队列来存储点。marked可以用dict,但是可以不用一上来先遍历一遍所有点并把它们添加到marked里面然后设置其值为1,而可以在BFS循环时每遇到一个再给里面加一个。记录步数可以不用额外的变量,而可以在队列中直接存储tuple(点,步数)。队列可以使用from queue import Queueq = Queue()也可以使用import collectionsqueue = collections.d

2020-10-21 14:56:02 112 1

原创 把列表转换为字典

创建一个全是空列表的字典:from collections import defaultdicta = [1,2,3]b = defaultdict(list)b["aaa"].append(1) # 可以直接appendb["aaa"]把两个列表的元素对应起来,创建字典:a = [1,2,3]c = [4,5,6]dict(zip(a,c))...

2020-10-21 14:11:47 1666

原创 change a series to a dataframe with index

2020-10-08 06:48:34 79

空空如也

空空如也

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

TA关注的人

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