原创 leetcode 303. 區域和檢索 - 數組不可變(線段樹解法、樹狀數組)
public class NumArray { private int [] tree; private int [] data; public NumArray(int [] nums){
原创 Coupon Collector's Problem高級算法設計
1 Geometric Distribution 用X表示n 次投擲coin(獨立伯努力分佈)中,首次出現正面時,投擲的次數,X可能的取值爲1,2,3,。。。N,假設每次正面的概率爲1/2(一般化可設爲p) 具體參考 2 Cou
原创 高級算法設計之 -- Derandomized MAXCUT Approximation
筆記來源:高級算法設計(孫曉明老師部分) 本文參考:http://people.seas.harvard.edu/~salil/pseudorandomness/basic.pdf 關於條件期望用於去隨機化的原理https:/
原创 高級算法設計 Chernoff Bounds
例子:獨立地擲硬n次,每一次正面的概率爲1/2,每次擲硬幣 事件爲xix_ixi那麼用XXX表示n次中正面向上的總次數,求當總次數超過平均次數n/2次約1/3的概率上限是多少? https://people.eecs.berke
原创 高級算法設計--條件期望去隨機化
筆記來源:高級算法設計(孫曉明老師部分) CPSC 536N: Randomized Algorithms https://www.cs.ubc.ca/~nickhar/W12/Lecture16Notes.pdf 本節主要學
原创 凸優化之內點法
Convex Optimization Stephen Boyd Department of Electrical Engineering Stanford University 第11章 本文爲筆者結合原書及博客https:/
原创 高級算法設計-代數化方法解決Bipartite Pefect Matching
筆記來源:高級算法設計(孫曉明老師部分) 利用PIT 解決二分圖完美匹配(代數化方法) 定理:AAA的行列式identicalzero,identical zero,identicalzero,即(恆等於0,PIT ),
原创 Relation extraction文章
Others 2020 No. Title paper Pub 8 Improving Neural Relation Extraction with Positive and Unlabeled Learning
原创 11. 盛最多水的容器(雙指針)
思路來源於84 題 從暴力到雙指針原理 暴力 class Solution { public: int maxArea(vector<int>& height) { int n=height.size(
原创 210. 課程表 II(拓撲排序 深度、廣度優先)
深度優先 class Solution { public: vector<vector<int>>edge; vector<int>res; bool invalid=false; vector<int>visited{0};
原创 152. 乘積最大子數組(動態規劃)
添加鏈接描述 class Solution { public: int maxProduct(vector<int>& nums) { int n=nums.size(); int dp[
原创 leetcode 20. 有效的括號(可以學習利用hashmap)
class Solution { public: bool _isValid(char a,char b){ if(a=='(') return b==')'; if(a=='[') re
原创 leetcode 677. 鍵值映射
class MapSum { private Node root; private class Node{ public int val; public TreeMap<Charac
原创 線段樹查詢
線段樹的查詢代碼 public E query(int queryL,int queryR){ if(queryL<0||queryL>=data.length||queryR<0||queryR>=data
原创 線段樹的更新及完整程序
線段樹的更新 SegmentTree.java public void set(int index,E e){ if(index<0||index>=data.length) th