├── .gitignore ├── .gitmodules ├── .vscode ├── c_cpp_properties.json ├── extensions.json ├── launch.json ├── settings.json ├── sftp.json ├── tasks.json └── templates │ ├── leetcode-easonsi.py │ ├── leetcode-singlefile.py │ ├── z-codeforce.py │ └── z-tmp.py ├── LC-contest ├── .vscode │ └── launch.json ├── 0x3 │ └── 0722.py ├── 151-200 │ ├── 150.py │ ├── 151.py │ ├── 152.py │ ├── 153.py │ ├── 154.py │ ├── 155.py │ ├── 156.py │ ├── 157.py │ ├── 158.py │ ├── 159.py │ ├── 160.py │ ├── 161.py │ ├── 162.py │ ├── 163.py │ ├── 164.py │ ├── 165.py │ ├── 166.py │ ├── 167.py │ ├── 168.py │ ├── 169.py │ ├── 170.py │ ├── 171.py │ ├── 172.py │ ├── 173.py │ ├── 174.py │ ├── 175.py │ ├── 176.py │ ├── 177.py │ ├── 178.py │ ├── 179.py │ ├── 180.py │ ├── 181.py │ ├── 182.py │ ├── 183.py │ ├── 184.py │ ├── 185.py │ ├── 186.py │ ├── 187.py │ ├── 188.py │ ├── 189.py │ ├── 190.py │ ├── 191.py │ ├── 192.py │ ├── 193.py │ ├── 194.py │ ├── 195.py │ ├── 196.py │ ├── 197.py │ ├── 198.py │ ├── 199.py │ └── 200.py ├── 201-250 │ ├── 201.py │ ├── 202.py │ ├── 203.py │ ├── 204.py │ ├── 205.py │ ├── 206.py │ ├── 207.py │ ├── 208.py │ ├── 209.py │ ├── 210.py │ ├── 211.py │ ├── 212.py │ ├── 213.py │ ├── 214.py │ ├── 215.py │ ├── 216.py │ ├── 217.py │ ├── 218.cpp │ ├── 218.py │ ├── 219.cpp │ ├── 219.py │ ├── 220.py │ ├── 221.py │ ├── 222.py │ ├── 223.py │ ├── 224.py │ ├── 225.py │ ├── 226.py │ ├── 227.py │ ├── 228.py │ ├── 229.py │ ├── 230.py │ ├── 231.py │ ├── 232.py │ ├── 233.py │ ├── 234.py │ ├── 235.py │ ├── 236.py │ ├── 237.py │ ├── 238.py │ ├── 239.py │ ├── 240.py │ ├── 241.py │ ├── 242.py │ ├── 243.py │ ├── 244.py │ ├── 245.py │ ├── 246.py │ ├── 247.py │ ├── 248.py │ ├── 249.py │ └── 250.py ├── 251-300 │ ├── 251.py │ ├── 252.py │ ├── 253.py │ ├── 254.py │ ├── 255.py │ ├── 256.py │ ├── 257.py │ ├── 258.py │ ├── 259.py │ ├── 260.py │ ├── 261.py │ ├── 262.py │ ├── 263.py │ ├── 264.py │ ├── 265.py │ ├── 266.py │ ├── 267.py │ ├── 268.go │ ├── 268.py │ ├── 269.py │ ├── 270.py │ ├── 271.py │ ├── 272.py │ ├── 273.py │ ├── 274.py │ ├── 275.py │ ├── 276.py │ ├── 277.py │ ├── 278.py │ ├── 279.py │ ├── 280.py │ ├── 281.py │ ├── 282.py │ ├── 283.py │ ├── 284.py │ ├── 285.py │ ├── 286.py │ ├── 287.py │ ├── 288.py │ ├── 289.py │ ├── 290.py │ ├── 291.py │ ├── 292.py │ ├── 293.py │ ├── 294.py │ ├── 295.py │ ├── 296.py │ ├── 297.py │ ├── 298.py │ ├── 299.py │ └── 300.py ├── 301-350 │ ├── 301.py │ ├── 302.py │ ├── 303.py │ ├── 304.py │ ├── 305.py │ ├── 306.py │ ├── 307.py │ ├── 308.py │ ├── 309.py │ ├── 310.py │ ├── 311.py │ ├── 312.py │ ├── 313.py │ ├── 314.py │ ├── 315.py │ ├── 316.py │ ├── 317.py │ ├── 318.py │ ├── 319.py │ ├── 320.py │ ├── 321.py │ ├── 322.py │ ├── 323.py │ ├── 324.py │ ├── 325.py │ ├── 326.py │ ├── 327.py │ ├── 328.py │ ├── 329.py │ ├── 330.py │ ├── 331.py │ ├── 332.py │ ├── 333.py │ ├── 334.py │ ├── 335.py │ ├── 336.py │ ├── 337.py │ ├── 338.py │ ├── 339.py │ ├── 340.py │ ├── 341.py │ ├── 342.py │ ├── 343.py │ ├── 344.py │ ├── 345.py │ ├── 346.py │ ├── 347.py │ ├── 348.py │ ├── 349.py │ ├── 350.py │ └── tmp.py ├── 351-400 │ ├── 351.py │ ├── 352.py │ ├── 353.py │ ├── 354.py │ ├── 355.py │ ├── 356.py │ ├── 357.py │ ├── 358.py │ ├── 359.py │ ├── 360.py │ ├── 361.py │ ├── 362.py │ ├── 363.py │ ├── 364.py │ ├── 365.py │ ├── 366.py │ ├── 367.py │ ├── 368.py │ ├── 369.py │ ├── 370.py │ ├── 371.py │ ├── 372.py │ ├── 373.py │ ├── 374.py │ ├── 375.py │ ├── 376.py │ ├── 377.py │ ├── 378.py │ ├── 379.py │ ├── 380.py │ ├── 381.py │ ├── 382.py │ ├── 383.py │ ├── 384.py │ ├── 385.py │ ├── 386.py │ ├── 387.py │ ├── 388.py │ ├── 389.py │ ├── 390.py │ ├── 391.py │ ├── 392.py │ ├── 393.py │ ├── 394.py │ ├── 395.py │ ├── 396.py │ ├── 397.py │ ├── 398.py │ ├── 399.py │ └── 400.py ├── 401-450 │ ├── 401.py │ ├── 402.py │ ├── 403.py │ ├── 404.py │ ├── 405.py │ ├── 406.py │ ├── 407.py │ ├── 408.py │ ├── 409.py │ ├── 410.py │ ├── 411.py │ ├── 412.py │ ├── 413.py │ ├── 414.py │ ├── 415.py │ ├── 416.py │ ├── 417.py │ ├── 418.py │ ├── 419.py │ ├── 420.py │ ├── 421.py │ ├── 422.py │ ├── 423.py │ ├── 424.py │ ├── 425.py │ ├── 426.py │ ├── 427.py │ ├── 428.py │ ├── 429.py │ └── 430.py ├── LCCUP-力扣杯 │ ├── 21-autumn.py │ ├── 22-personal.py │ ├── 22-team.py │ └── 23-string.py ├── acwing │ ├── 4626.py │ ├── 789-数的范围.cpp │ └── acwing-template.cpp ├── atcoder │ ├── 221e.py │ ├── 250e.py │ ├── Beginner Contest 191 │ │ ├── a.py │ │ └── f.py │ └── Beginner Contest 259 │ │ ├── 259.md │ │ ├── a.py │ │ ├── b.py │ │ ├── c.py │ │ ├── d.py │ │ └── d_py.py ├── codeforce │ ├── #804 (Div. 2) │ │ ├── a.py │ │ ├── b.py │ │ └── c.py │ ├── 131 (Rated for Div. 2) │ │ ├── a.py │ │ ├── b.py │ │ ├── c.py │ │ ├── d.py │ │ └── e.py │ ├── Codeforces Round #799 (Div. 4) │ │ ├── a.py │ │ ├── b.py │ │ ├── c.py │ │ ├── d.py │ │ ├── e.py │ │ ├── f.py │ │ ├── g.py │ │ ├── h.cpp │ │ ├── h.py │ │ └── input.txt │ ├── Codeforces Round #806 (Div. 4) │ │ └── a.py │ └── template │ │ ├── a.py │ │ ├── c │ │ └── c.py │ │ ├── d │ │ └── d.py │ │ └── input ├── d001-050 │ ├── d48.py │ ├── d49.py │ └── d50.py ├── d051-100 │ ├── d100.py │ ├── d51.py │ ├── d52.py │ ├── d53.py │ ├── d54.py │ ├── d55.py │ ├── d56.py │ ├── d57.py │ ├── d58.py │ ├── d59.py │ ├── d60.py │ ├── d61.py │ ├── d62.py │ ├── d63.py │ ├── d64.py │ ├── d65.py │ ├── d66.py │ ├── d67.py │ ├── d68.py │ ├── d69.py │ ├── d70.py │ ├── d71.py │ ├── d72.py │ ├── d73.py │ ├── d74.py │ ├── d75.py │ ├── d76.py │ ├── d77.py │ ├── d78.py │ ├── d79.py │ ├── d80.py │ ├── d81.py │ ├── d82.py │ ├── d83.py │ ├── d84.py │ ├── d85.py │ ├── d86.py │ ├── d87.py │ ├── d88.py │ ├── d89.py │ ├── d90.py │ ├── d91.py │ ├── d92.py │ ├── d93.py │ ├── d94.py │ ├── d95.py │ ├── d96.py │ ├── d97.py │ ├── d98.py │ └── d99.py ├── d101-150 │ ├── d101.py │ ├── d102.py │ ├── d103.py │ ├── d104.py │ ├── d105.py │ ├── d106.py │ ├── d107.py │ ├── d108.py │ ├── d109.py │ ├── d110.py │ ├── d111.py │ ├── d112.py │ ├── d113.py │ ├── d114.py │ ├── d115.py │ ├── d116.py │ ├── d117.py │ ├── d118.py │ ├── d119.py │ ├── d120.py │ ├── d121.py │ ├── d122.py │ ├── d123.py │ ├── d124.py │ ├── d125.py │ ├── d126.py │ ├── d127.py │ ├── d128.py │ ├── d129.py │ ├── d130.py │ ├── d131.py │ ├── d132.py │ ├── d133.py │ ├── d134.py │ ├── d135.py │ ├── d136.py │ ├── d137.py │ ├── d138.py │ ├── d139.py │ ├── d140.js │ └── d140.py ├── luogu │ ├── 1-入门 │ │ ├── 1001 │ │ │ ├── 1001.c │ │ │ ├── 1001.cpp │ │ │ ├── 1001.go │ │ │ ├── 1001.js │ │ │ └── 1001.py │ │ ├── 1014 │ │ │ ├── 1014.cpp │ │ │ └── 1014.py │ │ ├── 1035 │ │ │ └── 1035.py │ │ ├── 1046 │ │ │ └── 1046.py │ │ └── 1304 │ │ │ └── 1304.py │ ├── 2-普及- │ │ ├── 1002 │ │ │ └── 1002.py │ │ └── 1003 │ │ │ └── 1003.py │ ├── 3-普及~提高- │ │ ├── 1017 │ │ │ └── 1017.py │ │ ├── 1019 │ │ │ └── 1019.py │ │ ├── 1103 │ │ │ └── 1103.py │ │ └── 1106 │ │ │ └── 1106.py │ ├── 4-普及+~提高 │ │ ├── 1004 │ │ │ └── 1004.py │ │ ├── 1006 │ │ │ └── 1006.py │ │ └── 1016 │ │ │ ├── 1016.py │ │ │ └── input │ ├── 5-提高+~省选- │ │ └── P4513 小白逛公园 │ │ │ ├── P4513 小白逛公园.py │ │ │ ├── P4513_2.in │ │ │ └── P4513_2.out │ └── README.md ├── misc │ ├── 22hulu.py │ ├── 22银联.py │ ├── tianchi2022天池.py │ └── zj-future.py ├── others.py ├── record-contest.md ├── structures.py └── utils_leetcode.py ├── LC-daily ├── daily2201.py ├── daily2202.js ├── daily2202.py ├── daily2205.py ├── daily2207.py ├── daily2209.py ├── daily2210.py └── daily2301.py ├── LC-go ├── .vscode │ ├── launch.json │ └── settings.json ├── 00-base │ └── algorithms.go ├── DFS │ └── dfs.go ├── SlidingWindow │ └── sliding-window.go ├── array │ └── array.go ├── backtrack │ └── backtracking.go ├── binnary-search │ └── bisearch.go ├── contest │ └── 274.go ├── dp │ └── dp.go ├── go.mod ├── go.sum ├── math │ └── math.go ├── others │ └── others.go ├── structure │ └── structure.go ├── structures │ ├── Heap.go │ ├── Heap_test.go │ ├── Interval.go │ ├── Interval_test.go │ ├── ListNode.go │ ├── ListNode_test.go │ ├── NestedInteger.go │ ├── NestedInterger_test.go │ ├── Point.go │ ├── Point_test.go │ ├── PriorityQueue.go │ ├── PriorityQueue_test.go │ ├── Queue.go │ ├── Queue_test.go │ ├── Stack.go │ ├── Stack_test.go │ ├── TreeNode.go │ └── TreeNode_test.go ├── templates │ └── binarySearch.go ├── tour.go └── useful-codes.md ├── LC-notes ├── 01-分类总结 │ └── 分类.md ├── LeetCode 刷题记录.md ├── Leetcode-contests.md ├── Leetcode-daily.md ├── Leetcode-first-100.md ├── Leetcode-思路总结.md ├── Python-advanced.md ├── Python-base.md ├── jgc-Hot100.md ├── jgc-代码模板.md ├── language-parctise.md ├── leetcode_guide.py ├── luogu-main.md └── media │ ├── 16057577754268 │ └── 16057581777903.jpg │ ├── 16147360600817 │ ├── 16147419822017.jpg │ ├── 16147420077589.jpg │ ├── 16147462117985.jpg │ ├── 16147508756483.jpg │ ├── 16149076152534.jpg │ ├── 16150005177904.jpg │ ├── 16150045759234.jpg │ ├── 16150104215412.jpg │ ├── 16150105404456.jpg │ ├── 16150459126250.jpg │ ├── 16150864008703.jpg │ ├── 16150882727746.jpg │ ├── 16151688033551.jpg │ ├── 16151693202715.jpg │ ├── 16151766304739.jpg │ ├── 16153075223021.jpg │ ├── 16153887376582.jpg │ ├── 16153908549608.jpg │ ├── 16154269940737.jpg │ ├── 16154270505502.jpg │ ├── 16154272302558.jpg │ └── 16155651378139.jpg │ └── Codeforce.md ├── Mathematica ├── .gitignore ├── Mathematica.md └── doc │ ├── basic.md │ ├── mathematica1-lang.md │ └── mathematica2-core-lang.md ├── README.md ├── algorithm-ds-templates ├── Basic-算法基础 │ ├── Sort-排序 │ │ ├── BinarySearch.py │ │ ├── bubbleSort-冒泡排序.py │ │ ├── heapSort.py │ │ ├── quickSort-快排.py │ │ ├── sort-leetbook.py │ │ ├── sort-misc.py │ │ ├── sort-template.py │ │ └── 逆序对.py │ ├── binaryLifting+倍增.py │ ├── bisearch-二分搜索 │ │ ├── binary-search-leetbook.py │ │ ├── bisearch-0x3f.py │ │ ├── bisearch-bisect.py │ │ ├── bisearch-misc.py │ │ ├── bisearch.md │ │ ├── bisearch_template.py │ │ └── interview-二分.md │ ├── construction-构造 │ │ └── construction.py │ ├── half-折半枚举 │ │ └── subset_half.py │ ├── prefix-sum-前缀和-差分.py │ ├── prefix-前缀和 │ │ └── prefix.py │ ├── simulation-模拟 │ │ └── simulation.py │ ├── slidingWindow-滑动窗口 │ │ ├── interview-滑窗.md │ │ ├── slidingWindow+滑动窗口.py │ │ └── sw-循环不变量.py │ └── two-pointer-双指针 │ │ ├── bipointer-同向双指针.py │ │ └── bipointer-相向双指针.py ├── DP-动态规划 │ ├── Knapsack-背包 │ │ ├── 01bag-template.py │ │ ├── 01bag-背包.py │ │ └── Knapsack-index.py │ ├── dp-DGA.py │ ├── dp-leetbook.py │ ├── dp-misc.py │ ├── dp-number+数位DP.py │ ├── dp-optim-misc.py │ ├── dp-subset-子集枚举.py │ ├── dp.py │ ├── index-DP.md │ ├── z-DP-string.py │ ├── z-DP-括号.py │ ├── 区间DP │ │ └── dp-区间DP.py │ ├── 树形DP │ │ └── dp-tree-树形DP.py │ └── 线性DP │ │ ├── misc-dp.py │ │ ├── z-DP-买卖股票.py │ │ ├── z-DP-打家劫舍.py │ │ └── z-LCS-最长公共子序列.py ├── DS-数据结构 │ ├── BIT-树状数组 │ │ ├── BinaryIndexedTree-fenwick.py │ │ ├── BinaryIndexedTree-树状数组.md │ │ └── loj130.py │ ├── LinkedList-链表 │ │ ├── linked-list-leetbook.py │ │ ├── linked-list-list.py │ │ ├── linkedlist-template.py │ │ ├── z-reverse-反转链表.py │ │ ├── z-前后指针-链表去重.py │ │ └── z-快慢指针-环形链表.py │ ├── SegTree-线段树 │ │ ├── list_solution.py │ │ └── segment-tree.py │ ├── Stack-栈 │ │ ├── stack-calculator.py │ │ └── stack.py │ ├── ds-guide.py │ ├── hash-dict-哈希表 │ │ ├── hash-table.py │ │ └── hash.md │ ├── heap-堆 │ │ ├── heap-implementation.py │ │ └── heap-堆.py │ ├── mono-单调栈-队列 │ │ ├── misc-stack+单调栈.py │ │ ├── mono-deque-单调队列.py │ │ ├── mono-index.md │ │ ├── mono-stack-单调栈.py │ │ ├── z-stack-matrix-矩阵系列.py │ │ └── z-stack-贡献法.py │ └── 并查集 │ │ ├── union-find.py │ │ └── union-set-template.py ├── Graph-图论 │ ├── BinaryTree-二叉树 │ │ ├── AVL.py │ │ ├── BinarySearchTree-LeetBook.py │ │ ├── BinaryTree-LeetBook.py │ │ ├── BinaryTree-二叉树.md │ │ ├── BinaryTree-二叉树.py │ │ ├── z- BFS-二叉树的层序遍历.py │ │ ├── z-二叉搜索树.py │ │ ├── z-二叉树递归.py │ │ ├── z-对称-平衡.py │ │ └── z-最近公共祖先.py │ ├── Euler-欧拉图.py │ ├── Topo-拓扑排序 │ │ └── topological-sort.py │ ├── bi-graph-二分图 │ │ └── BinaryGraph-二分图.py │ ├── connection-连通性 │ │ ├── Tarjan+SCC.py │ │ └── Trajan-NOTE.py │ ├── graph-match-图匹配 │ │ └── graph-match.py │ ├── graph-misc.py │ ├── interview-图算法.md │ ├── min-circle.py │ ├── search-BFS-DFS │ │ ├── 01BFS.py │ │ └── search+BFS+DFS.py │ └── shortest-path-最短路 │ │ ├── Dijkstra-单源最短路.py │ │ └── shorted-path.py ├── README.md ├── Search-搜索 │ ├── A*.py │ ├── Backtracking-回溯 │ │ ├── backtracking-子集型回溯.py │ │ ├── backtracking-排列型回溯.py │ │ ├── backtracking-组合型回溯.py │ │ └── bracktracking.py │ ├── alpha-beta-剪枝.py │ ├── bidirectional-search-双向搜索.py │ └── interview-回溯.md ├── geometry-计算几何 │ └── geo.py ├── interview-algo-index.md ├── leetbook.md ├── math-数学 │ ├── bignum-高精度计算.py │ ├── binary-set-二进制集合操作 │ │ └── binary-set-二进制集合操作.py │ ├── binpow-快速幂 │ │ ├── binpow-快速幂.py │ │ └── quick-multipy.py │ ├── bit-位运算 │ │ ├── bit-utils.py │ │ ├── bit-位运算.py │ │ └── z-只出现一次的数字.py │ ├── computer-int.py │ ├── game-博弈论 │ │ └── game-博弈论.py │ ├── integral-数值积分.py │ ├── math-misc.py │ ├── math.py │ ├── number-theory-数论 │ │ ├── Fermat-Euler-费马小定理-欧拉定理.py │ │ ├── gcd-最大公约数.py │ │ └── sieve-筛法.py │ ├── perm+comb+排列组合.py │ ├── permulation-置换和排列.py │ └── ploy-多项式与生成函数 │ │ └── FTT-快速傅立叶变换.py ├── misc │ ├── z-区间操作.py │ ├── z-最大子数组和.py │ └── 句法分析 │ │ └── compile.py ├── string-字符串 │ ├── AC-automaton │ │ ├── AC自动机.md │ │ └── ac.py │ ├── Automaton-自动机 │ │ └── DFA-Automaton.py │ ├── KMP │ │ ├── KMP-template.py │ │ ├── KMP.md │ │ └── kmp.py │ ├── Manacher-马拉车 │ │ └── Manacher+马拉车.py │ ├── Trie-字典树 │ │ ├── trie+字典树.py │ │ └── trie_template.py │ ├── Z-func-Z函数 │ │ ├── Z-function.py │ │ └── z_func-template.py │ ├── hash-字符串哈希 │ │ └── string-hash-Rabin-Karp.py │ ├── string-misc.py │ └── z-回文.py └── template.py ├── cpp ├── .vscode │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── README.md ├── cpp-hackerrank │ ├── basic │ │ ├── 1-hello-world.cpp │ │ ├── 2-basic-datatype.cpp │ │ ├── 3-if-condition.cpp │ │ ├── 4-for-loop.cpp │ │ ├── 5-function.cpp │ │ ├── 6-pointer.cpp │ │ ├── 7-arrays.cpp │ │ ├── 8-variable-sized-arraya.cpp │ │ └── io-scanf-printf.cpp │ ├── helloworld.cpp │ └── intermediate │ │ ├── 1-error-exceptional.cpp │ │ ├── 2-virtual-functions.cpp │ │ └── cpp2.md ├── cpp-leatcode │ ├── 2207.cpp │ ├── 3sum.cpp │ ├── makefile │ ├── run.sh │ └── template.cpp ├── doc │ ├── cpp-STL-note.md │ ├── cpp-make.md │ ├── cpp-note.md │ └── cpp-roadmap.md ├── fork-clone │ ├── clone.c │ ├── fork.c │ └── vfork.c ├── learn-STL │ ├── 211-vector.cpp │ ├── 253-vector-vector.cpp │ ├── 312-string-construct.cpp │ ├── 321-vector.cpp │ ├── 330-deque.cpp │ ├── 340-example.cpp │ ├── 350-stack.cpp │ ├── 360-queue.cpp │ ├── 370-list.cpp │ └── stl.md ├── learn-cpp-basic │ ├── class │ │ ├── 2-6-constructor-default.cpp │ │ ├── 2-6-constructor.cpp │ │ └── 2-8-destructor.cpp │ ├── makefile │ ├── run.sh │ └── tmp.cpp ├── learn-cpp-heima │ ├── 100-template.cpp │ ├── 100-template2.cpp │ ├── 123-template-sort.cpp │ ├── 126-template-overload.cpp │ ├── 131-template-class.cpp │ ├── 133-template-class-func.cpp │ ├── 134-template-class-as-para.cpp │ ├── 135-template-class-inhertance.cpp │ ├── 137-name.cpp │ ├── 137-name.h │ ├── 137-name.hpp │ ├── 137-template-class-split-file.cpp │ ├── 138-template-class-friend.cpp │ ├── 139-myarray.hpp │ ├── 139-template-myarray.cpp │ ├── 44-friend.cpp │ ├── 45-operator++.cpp │ ├── 45-operator+.cpp │ ├── 45-operator-call.cpp │ ├── 45-operator=.cpp │ ├── 45-operator==.cpp │ ├── 46-inheritance.cpp │ ├── 465-inheritance.cpp │ ├── 467-multi-inheritance.cpp │ ├── 468-rect-inderitance.cpp │ ├── 471-multimorphism.cpp │ ├── 474-virtual-func.cpp │ ├── 476-example-computer.cpp │ ├── 510-fstream.cpp │ ├── 520-io-binary.cpp │ ├── person.txt │ ├── readme.md │ └── test.txt ├── make │ └── 01-single-src │ │ ├── main.c │ │ ├── makefile │ │ └── makefile.v1 ├── misc │ ├── base │ │ ├── 01-basic.cpp │ │ ├── 02-data-type.cpp │ │ ├── 03-const.cpp │ │ ├── 04-static.cpp │ │ ├── 05-nested-loop.cpp │ │ ├── 06-guess-number.cpp │ │ ├── 07-function-call.cpp │ │ ├── 08-string.cpp │ │ ├── 09-pointer.cpp │ │ ├── 10-array-of-pointers.cpp │ │ ├── 11-passing-pointer-to-func.cpp │ │ ├── 12-returning-value-as-reference.cpp │ │ ├── 13-ctime.cpp │ │ ├── 14-struct.cpp │ │ ├── 15-class.cpp │ │ ├── 16-class-access.cpp │ │ ├── 17-constructor-deconstructor.cpp │ │ ├── 18-copy-constructor.cpp │ │ ├── 19-class-construct.cpp │ │ ├── 20-static-membership.cpp │ │ ├── 21-class-const.cpp │ │ ├── func-overload.cpp │ │ ├── helloworld.cpp │ │ ├── main.cpp │ │ ├── memory-space.cpp │ │ └── try.cpp │ └── helloworld │ │ └── helloworld.cpp ├── pj1-contect │ └── management-system.cpp ├── pj2-manage-system │ ├── README.md │ ├── boss.cpp │ ├── boss.h │ ├── empFile.txt │ ├── employee.cpp │ ├── employee.h │ ├── main.cpp │ ├── manager.h │ ├── managerr.cpp │ ├── worker.h │ ├── workerManager.cpp │ └── workerManager.h └── test │ ├── t-array.cpp │ ├── t-struct │ └── t-struct.cpp ├── docs └── javascript.md ├── go ├── .vscode │ ├── launch.json │ └── settings.json ├── README.md ├── learn-go │ ├── f-ck-need-u │ │ └── 101.go │ ├── go.mod │ ├── go.sum │ ├── misc │ │ ├── int.go │ │ ├── slice.go │ │ └── string.go │ └── test-gopl │ │ ├── ch4 │ │ └── 4-1.go │ │ ├── test.go │ │ └── testMod.go ├── note-go │ ├── go-note.md │ ├── go-outline.md │ └── gopl.md └── z-gopl │ ├── CNAME │ ├── README.md │ ├── ch1 │ ├── dup1 │ │ └── main.go │ ├── dup2 │ │ └── main.go │ ├── dup3 │ │ └── main.go │ ├── echo1 │ │ └── main.go │ ├── echo2 │ │ └── main.go │ ├── echo3 │ │ └── main.go │ ├── fetch │ │ └── main.go │ ├── fetchall │ │ └── main.go │ ├── helloworld │ │ └── main.go │ ├── lissajous │ │ └── main.go │ ├── server1 │ │ └── main.go │ ├── server2 │ │ └── main.go │ └── server3 │ │ └── main.go │ ├── ch10 │ ├── cross │ │ └── main.go │ └── jpeg │ │ └── main.go │ ├── ch11 │ ├── echo │ │ ├── echo.go │ │ └── echo_test.go │ ├── storage1 │ │ └── storage.go │ ├── storage2 │ │ ├── quota_test.go │ │ └── storage.go │ ├── word1 │ │ ├── word.go │ │ └── word_test.go │ └── word2 │ │ ├── word.go │ │ └── word_test.go │ ├── ch12 │ ├── display │ │ ├── display.go │ │ └── display_test.go │ ├── format │ │ ├── format.go │ │ └── format_test.go │ ├── methods │ │ ├── methods.go │ │ └── methods_test.go │ ├── params │ │ └── params.go │ ├── search │ │ └── main.go │ └── sexpr │ │ ├── decode.go │ │ ├── encode.go │ │ ├── pretty.go │ │ └── sexpr_test.go │ ├── ch13 │ ├── bzip-print │ │ ├── bzip2.c │ │ ├── bzip2.go │ │ └── bzip2_test.go │ ├── bzip │ │ ├── bzip2.c │ │ ├── bzip2.go │ │ └── bzip2_test.go │ ├── bzipper │ │ └── main.go │ ├── equal │ │ ├── equal.go │ │ └── equal_test.go │ └── unsafeptr │ │ └── main.go │ ├── ch2 │ ├── boiling │ │ └── main.go │ ├── cf │ │ └── main.go │ ├── echo4 │ │ └── main.go │ ├── ftoc │ │ └── main.go │ ├── popcount │ │ ├── main.go │ │ └── popcount_test.go │ ├── tempconv │ │ ├── conv.go │ │ └── tempconv.go │ └── tempconv0 │ │ ├── celsius.go │ │ └── tempconv_test.go │ ├── ch3 │ ├── basename1 │ │ └── main.go │ ├── basename2 │ │ └── main.go │ ├── comma │ │ └── main.go │ ├── mandelbrot │ │ └── main.go │ ├── netflag │ │ └── netflag.go │ ├── printints │ │ └── main.go │ └── surface │ │ └── main.go │ ├── ch4 │ ├── append │ │ └── main.go │ ├── autoescape │ │ └── main.go │ ├── charcount │ │ └── main.go │ ├── dedup │ │ └── main.go │ ├── embed │ │ └── main.go │ ├── github │ │ ├── github.go │ │ └── search.go │ ├── graph │ │ └── main.go │ ├── issues │ │ └── main.go │ ├── issueshtml │ │ └── main.go │ ├── issuesreport │ │ └── main.go │ ├── movie │ │ └── main.go │ ├── nonempty │ │ └── main.go │ ├── rev │ │ └── main.go │ ├── sha256 │ │ └── main.go │ └── treesort │ │ ├── sort.go │ │ └── sort_test.go │ ├── ch5 │ ├── defer1 │ │ └── defer.go │ ├── defer2 │ │ └── defer.go │ ├── fetch │ │ └── main.go │ ├── findlinks1 │ │ └── main.go │ ├── findlinks2 │ │ └── main.go │ ├── findlinks3 │ │ └── findlinks.go │ ├── links │ │ └── links.go │ ├── outline │ │ └── main.go │ ├── outline2 │ │ └── outline.go │ ├── squares │ │ └── main.go │ ├── sum │ │ └── main.go │ ├── title1 │ │ └── title.go │ ├── title2 │ │ └── title.go │ ├── title3 │ │ └── title.go │ ├── toposort │ │ └── main.go │ ├── trace │ │ └── main.go │ └── wait │ │ └── wait.go │ ├── ch6 │ ├── coloredpoint │ │ └── main.go │ ├── geometry │ │ └── geometry.go │ ├── intset │ │ ├── intset.go │ │ └── intset_test.go │ └── urlvalues │ │ └── main.go │ ├── ch7 │ ├── bytecounter │ │ └── main.go │ ├── eval │ │ ├── ast.go │ │ ├── check.go │ │ ├── coverage_test.go │ │ ├── eval.go │ │ ├── eval_test.go │ │ ├── parse.go │ │ └── print.go │ ├── http1 │ │ └── main.go │ ├── http2 │ │ └── main.go │ ├── http3 │ │ └── main.go │ ├── http3a │ │ └── main.go │ ├── http4 │ │ └── main.go │ ├── sleep │ │ └── sleep.go │ ├── sorting │ │ └── main.go │ ├── surface │ │ └── surface.go │ ├── tempconv │ │ └── tempconv.go │ ├── tempflag │ │ └── tempflag.go │ └── xmlselect │ │ └── main.go │ ├── ch8 │ ├── cake │ │ ├── cake.go │ │ └── cake_test.go │ ├── chat │ │ └── chat.go │ ├── clock1 │ │ └── clock.go │ ├── clock2 │ │ └── clock.go │ ├── countdown1 │ │ └── countdown.go │ ├── countdown2 │ │ └── countdown.go │ ├── countdown3 │ │ └── countdown.go │ ├── crawl1 │ │ └── findlinks.go │ ├── crawl2 │ │ └── findlinks.go │ ├── crawl3 │ │ └── findlinks.go │ ├── du1 │ │ └── main.go │ ├── du2 │ │ └── main.go │ ├── du3 │ │ └── main.go │ ├── du4 │ │ └── main.go │ ├── netcat1 │ │ └── netcat.go │ ├── netcat2 │ │ └── netcat.go │ ├── netcat3 │ │ └── netcat.go │ ├── pipeline1 │ │ └── main.go │ ├── pipeline2 │ │ └── main.go │ ├── pipeline3 │ │ └── main.go │ ├── reverb1 │ │ └── reverb.go │ ├── reverb2 │ │ └── reverb.go │ ├── spinner │ │ └── main.go │ └── thumbnail │ │ ├── main.go │ │ ├── thumbnail.go │ │ └── thumbnail_test.go │ ├── ch9 │ ├── bank1 │ │ ├── bank.go │ │ └── bank_test.go │ ├── bank2 │ │ ├── bank.go │ │ └── bank_test.go │ ├── bank3 │ │ ├── bank.go │ │ └── bank_test.go │ ├── memo1 │ │ ├── memo.go │ │ └── memo_test.go │ ├── memo2 │ │ ├── memo.go │ │ └── memo_test.go │ ├── memo3 │ │ ├── memo.go │ │ └── memo_test.go │ ├── memo4 │ │ ├── memo.go │ │ └── memo_test.go │ ├── memo5 │ │ ├── memo.go │ │ └── memo_test.go │ └── memotest │ │ └── memotest.go │ ├── go.mod │ └── go.sum ├── interview-list ├── 230310-xiecheng-携程 │ └── 2303-xiecheng.md ├── 230311-meituan-美团 │ ├── meituan.py │ ├── meituan.sh │ ├── meituan2.py │ ├── meituan2.sh │ ├── meituan3.py │ └── meituan3.sh ├── 230312-duoduo-拼多多 │ ├── 2303-duoduo.md │ ├── duoduo3.py │ ├── duoduo3.sh │ ├── duoduo4.py │ └── duoduo4.sh ├── 230313-baidu-百度 │ ├── 01.py │ └── 01.sh ├── 230315-hackerrate │ ├── 4-3-mergesort-inverse.py │ ├── 4-3.sh │ ├── 5-1-merge-llist.py │ ├── 5-2-queue-stask.py │ ├── 5-2.sh │ ├── 5-3-brackets.py │ ├── 6-1-text-editor.py │ ├── 6-2-dp-blocks.py │ ├── 6-2.sh │ ├── 6-3-heap.py │ ├── 6-4-BFS.py │ ├── 7-1-tree-preorder.py │ ├── 7-1.sh │ ├── 7-2-Huffman.py │ ├── 7-2.sh │ ├── 7-3-preset-DictTree.py │ └── 7-3.sh ├── 230315-optiver │ ├── 1.cpp │ ├── 1.py │ ├── 1.sh │ ├── 2.cpp │ ├── 2.py │ ├── 2.sh │ └── README.txt ├── 230316-ant-蚂蚁 │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ └── ant-230316.md ├── 230319-miHoYo-米哈游 │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 230319-miHoYo.md │ ├── 3.py │ ├── 3.sh │ ├── a.py │ └── b.py ├── 230321-ant-deer │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── a.py │ └── ant.md ├── 230326-tecent │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 230326-tencent.md │ ├── 3.py │ ├── 3.sh │ ├── 3_2.py │ ├── 4.py │ ├── 4.sh │ ├── 4_2.py │ ├── 5.py │ ├── 5.sh │ └── 5_2.py ├── 230329-携程-deer │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ ├── 4.sh │ └── xiecheng.md ├── 230330-pdd-拼多多 │ ├── 1.py │ ├── 1.sh │ ├── 1_2.py │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ └── 4.sh ├── 230406-Morgan-Stanley │ ├── 0.py │ ├── 2.py │ └── 3.py ├── 230408-Meituan │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 230408-Meituan.md │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ └── 4.sh ├── 230412-alibaba │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 230412-ali.md │ ├── 3.py │ └── 3.sh ├── 230415-携程 │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 230415-xiecheng.md │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ └── 4.sh ├── 230419-jgc-Ali │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ └── ali_random_choice.py ├── 230419-pinduoduo │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ └── 4.sh ├── 230422-deer-Meituan │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ └── 4.sh ├── 230426-Amazon │ ├── 1.py │ └── 2.py ├── 230428-Merchants-招商银行 │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── Merchants.md │ └── t.py ├── 230502-Merchants-招商银行 │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 230502.md │ ├── 3.py │ └── 3.sh ├── 230722-oppo │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ └── 3.sh ├── 230729-Shein-NLP │ ├── 1.py │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ └── shein.md ├── 230729-Shein │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ └── shein.md ├── 230806-Mihayou │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ └── 3.sh ├── 230812-Meituan │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ └── 4.sh ├── 230822-pdd │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.go │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ └── 4.sh ├── 230827-Jingdong │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ └── 3.sh ├── 230903-莉莉丝 │ └── lilith.md ├── 230909-美团 │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ └── 4.sh ├── 230909-面试题 │ ├── 230415-tencent-1.py │ ├── 230417-ali-1_1.py │ ├── 230417-ali-1_2.py │ ├── 230425-deer-Meituan.py │ ├── 230426-deer-pdd.py │ ├── 230822-lilith.md │ └── employee.java ├── 230910-Tencent │ ├── 1.md │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ └── 3.sh ├── 230912-Baidu │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ └── 3.sh ├── 230926-IYQ │ ├── 1.py │ ├── 2.py │ └── ML+数学题.md ├── 230926-ant-蚂蚁 │ ├── 1.py │ ├── 2.py │ ├── 3.py │ └── 3.sh ├── 231108-huawei │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ └── 3.sh ├── 231108-华泰 │ ├── 1.py │ └── 2.py ├── 231109-shopee │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ └── 3.sh ├── 240317-小红书-test │ ├── 1.py │ ├── 2.py │ └── 3.py ├── 240324-小红书 │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ └── 3.sh ├── 240330-Meituan-test │ ├── 0.py │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ ├── 4.sh │ └── readmd.md ├── 240330-Meituan │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2.sh │ ├── 3.py │ ├── 3.sh │ ├── 4.py │ ├── 4.sh │ ├── 5.py │ └── 5.sh ├── 240406-Meituan │ ├── 1.py │ ├── 2.py │ ├── 3.py │ ├── 3_gen.py │ ├── 4.py │ └── 5.py ├── 240407-小红书 │ ├── 1.py │ ├── 2.py │ └── 3.py ├── 999999-template │ ├── 1.py │ ├── 2.py │ └── 3.py ├── 999999-utils │ └── 0.py ├── company-readme.md ├── hot100.md ├── hot100 │ └── hot100.py ├── index-面试题.md ├── inter-notes.md ├── leetcode-company │ ├── amazon.py │ ├── byteDance.py │ ├── google.py │ └── microsoft.py ├── misc-interview │ ├── 1.py │ ├── 1.sh │ ├── 2.py │ ├── 2209-hulu-hard.md │ ├── 2209-meituan-basic.md │ ├── 230202-byte.py │ ├── 2303-byte.md │ ├── 2303-byte.py │ ├── 230801-baidu.py │ ├── 230802.py │ ├── 230809-shein.py │ ├── 230809-快手.py │ ├── 230814-OPPO.py │ ├── 230816-米哈游一面.py │ └── auc.py └── others │ ├── 001-被三整除.py │ ├── 002-安置路灯.py │ ├── 003-闹钟起床.py │ └── Newcoder-Huawei │ ├── 字符串分割.py │ ├── 计算某字母出现次数.py │ ├── 质数因子.py │ ├── 进制转换.py │ └── 随机数去重.py ├── interview ├── ML-NLP-master │ ├── Deep Learning │ │ ├── 10. Neural Network │ │ │ ├── README.md │ │ │ └── TensorFlow_LR.ipynb │ │ ├── 11. CNN │ │ │ ├── CNN.ipynb │ │ │ └── README.md │ │ ├── 12. RNN │ │ │ ├── README.md │ │ │ └── RNN.ipynb │ │ ├── 12.1 GRU │ │ │ ├── GRU.ipynb │ │ │ └── README.md │ │ ├── 12.2 LSTM │ │ │ ├── LSTM.ipynb │ │ │ └── README.md │ │ ├── 13. Transfer Learning │ │ │ ├── README.md │ │ │ └── Transfer Learning.ipynb │ │ ├── 14. Reinforcement Learning │ │ │ └── README.md │ │ ├── 15. DL Optimizer │ │ │ └── README.md │ │ └── README.md │ ├── Machine Learning │ │ ├── 2.Logistics Regression │ │ │ ├── 2.Logistics Regression.md │ │ │ ├── README.md │ │ │ └── demo │ │ │ │ ├── CreditScoring.ipynb │ │ │ │ └── README.md │ │ ├── 3.1 Random Forest │ │ │ ├── 3.1 Random Forest.md │ │ │ ├── README.md │ │ │ └── RandomForestRegression.ipynb │ │ ├── 3.2 GBDT │ │ │ ├── 3.2 GBDT.md │ │ │ ├── GBDT_demo.ipynb │ │ │ ├── README.md │ │ │ ├── test_feat.txt │ │ │ └── train_feat.txt │ │ ├── 3.3 XGBoost │ │ │ ├── 3.3 XGBoost.ipynb │ │ │ ├── 3.3 XGBoost.md │ │ │ ├── README.md │ │ │ ├── pima-indians-diabetes.csv │ │ │ └── 数据说明.txt │ │ ├── 3.4 LightGBM │ │ │ ├── 3.4 LightGBM.ipynb │ │ │ ├── 3.4 LightGBM.md │ │ │ └── README.md │ │ ├── 3.Desition Tree │ │ │ ├── DecisionTree.ipynb │ │ │ ├── Desition Tree.md │ │ │ └── README.md │ │ ├── 4. SVM │ │ │ ├── 4. SVM.md │ │ │ ├── README.md │ │ │ └── news classification │ │ │ │ ├── README.md │ │ │ │ └── svm_classification.ipynb │ │ ├── 5.1 Bayes Network │ │ │ ├── 5.1 Bayes Network.md │ │ │ ├── Naive Bayes Classifier.ipynb │ │ │ └── README.md │ │ ├── 5.2 Markov │ │ │ ├── 5.2 HMM.ipynb │ │ │ ├── 5.2 Markov.md │ │ │ └── README.md │ │ ├── 5.3 Topic Model │ │ │ ├── HillaryEmail.ipynb │ │ │ └── README.md │ │ ├── 6. EM │ │ │ ├── README.md │ │ │ └── gmm_em │ │ │ │ ├── README.md │ │ │ │ ├── genSample.py │ │ │ │ ├── gmm.data │ │ │ │ ├── gmm.py │ │ │ │ ├── main.py │ │ │ │ └── sample.data │ │ ├── 7. Clustering │ │ │ ├── GMM.ipynb │ │ │ ├── K-Means.ipynb │ │ │ ├── README.md │ │ │ └── corpus_train.txt │ │ ├── 8. ML特征工程和优化方法 │ │ │ └── README.md │ │ ├── 9. KNN │ │ │ ├── README.md │ │ │ └── handwritingClass │ │ │ │ ├── README.md │ │ │ │ ├── handwritingClass.py │ │ │ │ ├── testDigits.zip │ │ │ │ └── trainingDigits.zip │ │ ├── Liner Regression │ │ │ ├── 1.Liner Regression.md │ │ │ ├── README.md │ │ │ └── demo │ │ │ │ ├── README.md │ │ │ │ └── housing_price.py │ │ └── README.md │ ├── NLP │ │ ├── 16. NLP │ │ │ └── README.md │ │ ├── 16.1 Word Embedding │ │ │ ├── README.md │ │ │ └── word2vec.ipynb │ │ ├── 16.2 fastText │ │ │ ├── README.md │ │ │ └── fastText.ipynb │ │ ├── 16.3 GloVe │ │ │ ├── GloVe.ipynb │ │ │ └── README.md │ │ ├── 16.4 textRNN & textCNN │ │ │ ├── README.md │ │ │ ├── cnews_loader.py │ │ │ ├── cnn_model.py │ │ │ ├── rnn_model.py │ │ │ ├── textCNN.ipynb │ │ │ └── textRNN.ipynb │ │ ├── 16.5 seq2seq │ │ │ ├── README.md │ │ │ └── seq2seq.ipynb │ │ ├── 16.6 Attention │ │ │ ├── README.md │ │ │ ├── datautil.py │ │ │ ├── fanyichina │ │ │ │ ├── fromids │ │ │ │ │ └── README.md │ │ │ │ └── toids │ │ │ │ │ └── README.md │ │ │ ├── myjiebadict.txt │ │ │ ├── seq2seq_model.py │ │ │ ├── test.py │ │ │ └── train.ipynb │ │ ├── 16.7 Transformer │ │ │ └── README.md │ │ ├── 16.8 BERT │ │ │ ├── README.md │ │ │ ├── bert-Chinese-classification-task.md │ │ │ ├── data │ │ │ │ ├── dev.tsv │ │ │ │ ├── test │ │ │ │ └── train.tsv │ │ │ ├── download_glue_data.py │ │ │ ├── modeling.py │ │ │ ├── optimization.py │ │ │ ├── run.sh │ │ │ ├── run_classifier_word.py │ │ │ └── tokenization_word.py │ │ ├── 16.9 XLNet │ │ │ └── README.md │ │ └── README.md │ ├── Project │ │ ├── 17. Recommendation System │ │ │ └── README.md │ │ ├── 18. Intelligent Customer Service │ │ │ └── README.md │ │ └── README.md │ └── README.md ├── _DL │ ├── 240906.py │ └── excel_col.py ├── interview-README.md └── quant │ └── anxian.py ├── java ├── .gitignore ├── .vscode │ └── settings.json ├── 01.hello │ └── Hello.java ├── JAVA note.md ├── Maven_ │ ├── maven-hello │ │ ├── .classpath │ │ ├── .project │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── itranswarp │ │ │ │ └── learnjava │ │ │ │ └── Main.java │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── itranswarp │ │ │ └── learnjava │ │ │ └── MainTest.java │ └── maven-plugin │ │ ├── .classpath │ │ ├── .project │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── itranswarp │ │ └── learnjava │ │ └── Main.java ├── javaa │ ├── ListNode.java │ └── Solution.java ├── maven.md └── src │ ├── basic │ ├── ExecFloat.java │ ├── JoinChar.java │ ├── PrimaryStudent.java │ ├── SumOfInteger.java │ └── control │ │ ├── BasicIf.java │ │ └── BasicSwitch.java │ └── oop │ └── method │ ├── Main.java │ └── Person.java ├── js ├── .vscode │ └── launch.json ├── 451-js │ ├── jQuery-note.md │ ├── js-async-异步.md │ ├── js-mindmap.md │ ├── js-note.md │ ├── media │ │ └── js-note │ │ │ ├── 2022-02-10-16-16-07.png │ │ │ ├── 2022-02-10-16-22-43.png │ │ │ ├── 2022-02-10-16-42-39.png │ │ │ └── 2022-02-10-22-27-30.png │ └── node-js-note.md ├── Electron │ └── electron.md ├── OOC │ └── ooc.js ├── README.md ├── from-washu │ ├── 001-quickstart.js │ ├── Bloom-redis │ │ ├── app.js │ │ ├── archive_xiaongshu_cache.js │ │ ├── hellowrold.js │ │ ├── learn-ioredis.js │ │ ├── redis-pipline.js │ │ └── testCache.js │ ├── Kafka │ │ ├── hello-consumer.js │ │ └── hello-producer.js │ ├── README.md │ ├── ReBloom │ │ ├── getStarted.js │ │ ├── testCache.js │ │ └── testCollapse.js │ ├── elasticsearch-in-action-7.x │ │ ├── README.md │ │ ├── mapping.json │ │ └── populate.sh │ ├── kibana │ │ ├── example.txt │ │ └── official-quickstart.txt │ ├── learn-ElasticSearch │ │ ├── 001-quickstart.js │ │ ├── elasticsearch-in-action-7.x │ │ │ ├── README.md │ │ │ ├── mapping.json │ │ │ └── populate.sh │ │ ├── kibana │ │ │ ├── example.txt │ │ │ └── official-quickstart.txt │ │ ├── official-tutorial │ │ │ └── 000-intrduction.js │ │ ├── quick-start │ │ │ ├── data.json │ │ │ ├── index.js │ │ │ ├── search.js │ │ │ ├── search_term.js │ │ │ └── verify.js │ │ └── readme.md │ ├── mongo │ │ ├── 000-getstart-connect.js │ │ ├── 010-find.js │ │ ├── 012-insert.js │ │ ├── 014-update.js │ │ ├── 016-count.js │ │ └── 017-distinct.js │ ├── official-tutorial │ │ └── 000-intrduction.js │ ├── package.json │ ├── quick-start │ │ ├── data.json │ │ ├── index.js │ │ ├── search.js │ │ ├── search_term.js │ │ └── verify.js │ └── small-project │ │ └── mongodb-example │ │ └── app.js ├── jQuery │ └── selector.js ├── node │ ├── crypto │ │ ├── .vscode │ │ │ └── launch.json │ │ ├── aes.js │ │ ├── dh.js │ │ ├── hash.js │ │ ├── hmac.js │ │ ├── rsa-key.pem │ │ ├── rsa-prv.pem │ │ ├── rsa-pub.pem │ │ └── rsa.js │ ├── fs │ │ ├── .gitignore │ │ ├── .vscode │ │ │ └── launch.json │ │ ├── read_image_file_async.js │ │ ├── read_image_file_sync.js │ │ ├── read_text_file_async.js │ │ ├── read_text_file_sync.js │ │ ├── sample.png │ │ ├── sample.txt │ │ ├── use_buffer.js │ │ ├── use_stat.js │ │ ├── write_text_file_async.js │ │ └── write_text_file_sync.js │ ├── global │ │ ├── .vscode │ │ │ └── launch.json │ │ └── gl.js │ ├── http │ │ ├── .vscode │ │ │ └── launch.json │ │ ├── file_server.js │ │ ├── hello.js │ │ ├── static │ │ │ ├── css │ │ │ │ └── uikit.min.css │ │ │ ├── fonts │ │ │ │ ├── FontAwesome.otf │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ └── fontawesome-webfont.woff2 │ │ │ └── js │ │ │ │ └── jquery.min.js │ │ └── urls.js │ ├── module │ │ ├── .vscode │ │ │ └── launch.json │ │ ├── hello.js │ │ └── main.js │ ├── nodejs.md │ ├── os │ │ ├── .vscode │ │ │ └── launch.json │ │ └── get_os_info.js │ ├── stream │ │ ├── .gitignore │ │ ├── .vscode │ │ │ └── launch.json │ │ ├── copy_file.js │ │ ├── read_stream.js │ │ ├── sample.txt │ │ └── write_stream.js │ ├── timers │ │ ├── .vscode │ │ │ └── launch.json │ │ └── timers.js │ ├── tutor │ │ └── 1_new │ │ │ └── server.js │ └── web │ │ ├── db │ │ ├── hello-sequelize │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── config.js │ │ │ ├── init.sql │ │ │ └── package.json │ │ └── model-sequelize │ │ │ ├── .vscode │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── config-default.js │ │ │ ├── config-test.js │ │ │ ├── config.js │ │ │ ├── db.js │ │ │ ├── init-db.js │ │ │ ├── init.sql │ │ │ ├── model.js │ │ │ ├── models │ │ │ ├── Pet.js │ │ │ └── User.js │ │ │ └── package.json │ │ ├── koa │ │ ├── hello-koa │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ └── package.json │ │ ├── url-koa │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ └── package.json │ │ ├── url2-koa │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── controller.js │ │ │ ├── controllers │ │ │ │ ├── hello.js │ │ │ │ └── index.js │ │ │ └── package.json │ │ ├── use-nunjucks │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ └── package.json │ │ └── view-koa │ │ │ ├── .vscode │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── controller.js │ │ │ ├── controllers │ │ │ ├── index.js │ │ │ └── signin.js │ │ │ ├── package.json │ │ │ ├── static-files.js │ │ │ └── templating.js │ │ ├── log │ │ └── winston │ │ │ ├── .vscode │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── logger.js │ │ │ └── package.json │ │ ├── rest │ │ ├── rest-hello │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── controller.js │ │ │ ├── controllers │ │ │ │ └── api.js │ │ │ └── package.json │ │ └── rest-koa │ │ │ ├── .vscode │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── controller.js │ │ │ ├── controllers │ │ │ ├── api.js │ │ │ └── index.js │ │ │ ├── package.json │ │ │ ├── products.js │ │ │ ├── rest.js │ │ │ ├── static-files.js │ │ │ └── templating.js │ │ ├── test │ │ ├── async-test │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── data.txt │ │ │ ├── hello.js │ │ │ ├── package.json │ │ │ └── test │ │ │ │ └── await-test.js │ │ ├── hello-test │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── hello.js │ │ │ ├── package.json │ │ │ └── test │ │ │ │ └── hello-test.js │ │ └── koa-test │ │ │ ├── app.js │ │ │ ├── package.json │ │ │ ├── start.js │ │ │ └── test │ │ │ └── app-test.js │ │ ├── vue │ │ ├── form-vue │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── package.json │ │ │ └── static-files.js │ │ ├── hello-vue │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── package.json │ │ │ └── static-files.js │ │ ├── mini-excel │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── controller.js │ │ │ ├── controllers │ │ │ │ └── api.js │ │ │ ├── package.json │ │ │ ├── rest.js │ │ │ ├── saved-docs │ │ │ │ └── README │ │ │ └── static-files.js │ │ ├── vue-todo-2 │ │ │ ├── .vscode │ │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── controller.js │ │ │ ├── controllers │ │ │ │ └── api.js │ │ │ ├── package.json │ │ │ ├── rest.js │ │ │ └── static-files.js │ │ └── vue-todo │ │ │ ├── .vscode │ │ │ └── launch.json │ │ │ ├── app.js │ │ │ ├── package.json │ │ │ └── static-files.js │ │ └── ws │ │ ├── hello-ws │ │ ├── .vscode │ │ │ └── launch.json │ │ ├── app.js │ │ ├── package.json │ │ └── test.js │ │ └── ws-with-koa │ │ ├── .vscode │ │ └── launch.json │ │ ├── app.js │ │ ├── controller.js │ │ ├── controllers │ │ ├── index.js │ │ └── signin.js │ │ ├── nginx-sample.conf │ │ ├── package.json │ │ ├── static-files.js │ │ └── templating.js ├── quick start │ └── hello.js ├── static │ ├── css │ │ └── main.css │ └── js │ │ ├── jquery-3.6.0.js │ │ ├── underscore-esm.js │ │ └── underscore-umd.js ├── test.json ├── underscore │ └── underscore.js ├── 函数 │ └── basic.js ├── 标准对象 │ └── standard object.js ├── 浏览器 │ ├── ajax.js │ ├── canvas.js │ ├── elements.js │ ├── from.js │ ├── main.js │ └── promise.js └── 错误处理 │ └── err.js ├── package.json ├── pyproject.toml ├── python ├── Liaoxuefeng │ ├── 1-基础+函数.py │ ├── 2-高级特性.py │ ├── 3-1-函数式编程.py │ └── 3-4-装饰器.py ├── Python-NOTE.md ├── Python-cheatsheet.md ├── Python-index.md ├── Python-misc │ ├── Sudoku-数独.py │ ├── hello.py │ ├── python-ast.py │ └── python-speed.ipynb ├── YJR-PythonPJ │ ├── XO-game.py │ ├── _re.py │ └── main.py ├── beginning-python-3ed-master │ ├── 9781484200292.jpg │ ├── Chapter02 │ │ ├── listing2-1.py │ │ ├── listing2-2.py │ │ ├── listing2-3.py │ │ └── listing2-4.py │ ├── Chapter03 │ │ └── listing3-1.py │ ├── Chapter04 │ │ ├── listing4-1.py │ │ └── listing4-2.py │ ├── Chapter10 │ │ ├── listing10-1.py │ │ ├── listing10-10.py │ │ ├── listing10-11.py │ │ ├── listing10-12.txt │ │ ├── listing10-13.txt │ │ ├── listing10-14.txt │ │ ├── listing10-2.py │ │ ├── listing10-3.py │ │ ├── listing10-4.py │ │ ├── listing10-5.py │ │ ├── listing10-6.py │ │ └── listing10-8.py │ ├── Chapter11 │ │ ├── listing11-1.py │ │ ├── listing11-10.py │ │ ├── listing11-11.py │ │ ├── listing11-12.py │ │ ├── listing11-13.py │ │ ├── listing11-2.txt │ │ ├── listing11-3.txt │ │ ├── listing11-4.txt │ │ ├── listing11-5.txt │ │ ├── listing11-6.py │ │ ├── listing11-7.py │ │ ├── listing11-8.py │ │ └── listing11-9.py │ ├── Chapter12 │ │ └── listing12-1.py │ ├── Chapter13 │ │ ├── listing13-1.py │ │ └── listing13-2.py │ ├── Chapter14 │ │ ├── listing14-1.py │ │ ├── listing14-2.py │ │ ├── listing14-3.py │ │ ├── listing14-4.py │ │ ├── listing14-5.py │ │ ├── listing14-6.py │ │ ├── listing14-7.py │ │ ├── listing14-8.py │ │ └── listing14-9.py │ ├── Chapter15 │ │ ├── listing15-1.py │ │ ├── listing15-2.py │ │ ├── listing15-3.py │ │ ├── listing15-4.py │ │ ├── listing15-5.py │ │ ├── listing15-6.py │ │ └── listing15-7.py │ ├── Chapter16 │ │ ├── listing16-1.py │ │ ├── listing16-2.py │ │ └── listing16-3.py │ ├── Chapter17 │ │ ├── listing17-1.java │ │ ├── listing17-2.cs │ │ ├── listing17-3.c │ │ ├── listing17-4.py │ │ ├── listing17-5.i │ │ └── listing17-6.c │ ├── Chapter18 │ │ └── listing18-1.py │ ├── Chapter19 │ │ ├── listing19-1.cfg │ │ ├── listing19-2.py │ │ └── listing19-3.py │ ├── Chapter20 │ │ ├── listing20-1.txt │ │ ├── listing20-2.py │ │ ├── listing20-3.py │ │ ├── listing20-4.py │ │ ├── listing20-5.py │ │ └── listing20-6.py │ ├── Chapter21 │ │ ├── listing21-1.py │ │ ├── listing21-2.py │ │ └── listing21-3.py │ ├── Chapter22 │ │ ├── listing22-1.xml │ │ ├── listing22-2.py │ │ └── listing22-3.py │ ├── Chapter23 │ │ ├── listing23-1.py │ │ └── listing23-2.py │ ├── Chapter24 │ │ ├── listing24-1.py │ │ ├── listing24-2.py │ │ ├── listing24-3.py │ │ ├── listing24-4.py │ │ ├── listing24-5.py │ │ └── listing24-6.py │ ├── Chapter25 │ │ ├── listing25-1.py │ │ ├── listing25-2.py │ │ └── listing25-3.py │ ├── Chapter26 │ │ ├── listing26-1.sql │ │ ├── listing26-2.sql │ │ ├── listing26-3.sql │ │ ├── listing26-4.py │ │ ├── listing26-5.py │ │ ├── listing26-6.py │ │ ├── listing26-7.py │ │ └── listing26-8.py │ ├── Chapter27 │ │ ├── listing27-1.py │ │ ├── listing27-2.py │ │ └── listing27-3.py │ ├── Chapter28 │ │ ├── listing28-1.py │ │ └── listing28-2.py │ ├── Chapter29 │ │ ├── listing29-1.py │ │ ├── listing29-2.py │ │ ├── listing29-3.py │ │ └── listing29-4.py │ ├── LICENSE.txt │ ├── README.md │ ├── README.txt │ ├── contributing.md │ └── errata.md ├── helloworld.py ├── misc │ └── ref.py ├── notes │ ├── Python-Liaoxuefeng-廖雪峰.md │ ├── Python-note.md │ ├── media │ │ ├── Python note │ │ │ ├── 16087172700264.jpg │ │ │ ├── 16087230546557.jpg │ │ │ ├── 16087234265571.jpg │ │ │ ├── 16087238216033.jpg │ │ │ ├── 16087252956536.jpg │ │ │ ├── 16087276625102.jpg │ │ │ ├── 16087276753956.jpg │ │ │ ├── 16090356051025.jpg │ │ │ ├── 16090379558633.jpg │ │ │ ├── 16090386184186.jpg │ │ │ ├── 16090387250946.jpg │ │ │ ├── 16090389379048.jpg │ │ │ ├── 16090762594110.jpg │ │ │ ├── 16090762938863.jpg │ │ │ ├── 16090777817544.jpg │ │ │ ├── 16090780982856.jpg │ │ │ ├── 16090793142436.jpg │ │ │ ├── 16090797540028.jpg │ │ │ ├── 16090798648334.jpg │ │ │ ├── 16090824106434.jpg │ │ │ ├── 16090827528574.jpg │ │ │ ├── 16091292039635.jpg │ │ │ ├── 16091292718104.jpg │ │ │ ├── 16091327029724.jpg │ │ │ ├── 16091333143775.jpg │ │ │ ├── 16091335952821.jpg │ │ │ ├── 16091368085806.jpg │ │ │ ├── 16091381782490.jpg │ │ │ ├── 16091387408303.jpg │ │ │ ├── 16091423869167.jpg │ │ │ ├── 16091432750244.jpg │ │ │ ├── 16091436732720.jpg │ │ │ ├── 16091442591864.jpg │ │ │ ├── 16091452147197.jpg │ │ │ ├── 16091453853914.jpg │ │ │ ├── 16091473928674.jpg │ │ │ ├── 16091499702206.jpg │ │ │ ├── 16091502617049.jpg │ │ │ ├── 16091503717829.jpg │ │ │ ├── 16091504628480.jpg │ │ │ ├── 16091517544151.jpg │ │ │ └── 16091526454085.jpg │ │ └── python-readme │ │ │ └── 2022-08-03-14-37-18.png │ ├── python-modules.md │ └── python-运行原理.md ├── profile_ │ ├── line_ │ │ ├── line_profiler_1.py │ │ ├── line_profiler_2.py │ │ └── line_profiler_2.py.lprof │ └── profile_ │ │ ├── profile_1.py │ │ ├── profile_2.py │ │ ├── pstats_1.py │ │ └── restats ├── python-topics │ ├── Python-GUI-tkinter.md │ ├── Python-network-网络编程.md │ ├── Python-process-thread-线程与进程.md │ ├── Python-文件之间共享变量.md │ └── Python-重定向.md └── sql │ └── python-sql-NOTE.md ├── r ├── .gitignore ├── .vscode │ └── launch.json ├── README.md ├── basic │ ├── 11-列表类型.R │ ├── 12-矩阵.R │ ├── 13-数据框.R │ ├── 14-工作空间和变量赋值.R │ ├── 17-函数.R │ ├── 19-debug.R │ ├── 19-函数进阶.R │ ├── 26-数据整理.Rmd │ ├── 27-数据汇总.Rmd │ ├── 7-下标和集合.R │ ├── 8-R数据类型的性质.R │ └── basic.R ├── learn-r.Rproj └── notes │ ├── R-SL-note.md │ ├── R-mindmap.md │ ├── R-note.md │ └── R-plot.md ├── requirements.txt ├── rust ├── hello_world │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ ├── main.rs │ │ └── test.rs ├── learn-basic │ ├── .vscode │ │ └── launch.json │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ ├── 2-0-intro.rs │ │ ├── 2-1-variable.rs │ │ ├── 2-2-basic-type.rs │ │ ├── 2-2-fn.rs │ │ ├── 2-2-num.rs │ │ ├── 2-3-borow.rs │ │ ├── 2-3-ownership.rs │ │ ├── main.rs │ │ └── test.rs ├── notes-rust │ └── Rust.md └── readme.md ├── scripts ├── auto_commit.sh └── setup_auto_commit.sh ├── shell ├── 101_basic │ ├── infos.sh │ └── user.sh ├── examples │ └── 2312_fdu │ │ ├── chpasswd.sh │ │ ├── list_users.sh │ │ └── user_add.sh ├── if.sh └── services │ └── mysql.sh ├── sql ├── MySQL-note.md ├── leetcode-mysql │ ├── createTable.py │ ├── input.sql │ ├── leetcode-sql-base.sql │ └── sql-base50.sql ├── mysql-digging.md ├── mysql-maintain-debug.md ├── nowcoder │ └── run.sql └── sql-mysql+note.md ├── stat ├── CTL.py └── tt.py └── utils ├── hot100.md ├── hot100_crawel.py └── ranking_crawel.py /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/.gitmodules -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-vscode.cpptools", 4 | "ms-python.python" 5 | ] 6 | } -------------------------------------------------------------------------------- /.vscode/templates/z-codeforce.py: -------------------------------------------------------------------------------- 1 | """ Codeforce Python 模板 """ 2 | from easonsi.util.leetcode import * 3 | 4 | def f(): 5 | # 处理输入 6 | # n, s = map(int, input().split()) 7 | # nums = list(map(int, input().split())) 8 | # 返回 9 | return 10 | 11 | # 第一行是例子的数量. 12 | for _ in range(int(input())): 13 | print(f()) -------------------------------------------------------------------------------- /LC-contest/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Python Debugger: Current File", 9 | "type": "debugpy", 10 | "request": "launch", 11 | "program": "${file}", 12 | "console": "integratedTerminal" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /LC-contest/301-350/tmp.py: -------------------------------------------------------------------------------- 1 | 2 | #%% 3 | arr = [1,2,43,4]+ [1,2,3] 4 | brr = [3,2,4] 5 | for a,b in zip(arr,brr): 6 | print(f"{a} {b}") 7 | 8 | # for i in range(len(arr)): 9 | # print(f"{arr[i]} {brr[i]}") 10 | 11 | #%% 12 | zz = zip(arr,brr) 13 | zz[0] 14 | # %% 15 | -------------------------------------------------------------------------------- /LC-contest/atcoder/Beginner Contest 191/a.py: -------------------------------------------------------------------------------- 1 | """ A - Vanishing Pitch """ 2 | v, t,s, d = map(int, input().split()) 3 | if dv*s: print("Yes") 4 | else: print("No") -------------------------------------------------------------------------------- /LC-contest/atcoder/Beginner Contest 259/259.md: -------------------------------------------------------------------------------- 1 | [AtCoder Beginner Contest 259](https://atcoder.jp/contests/abc259/tasks) 2 | 3 | 心态爆炸. C一开始想错了, 重新写才过; D既卡时间又卡精度: 用srqt就会因为精度问题报错, 写个并查集自己为已经优化了很多了居然还WTL... 麻了 (是时间改成Go看看怎么样吧). 4 | -------------------------------------------------------------------------------- /LC-contest/atcoder/Beginner Contest 259/a.py: -------------------------------------------------------------------------------- 1 | """ 2 | A - Growth Record 3 | 4 | 5 | https://atcoder.jp/contests/abc259/tasks/abc259_a 6 | """ 7 | m,n,x,t,d = map(int, input().split()) 8 | if n>=x: 9 | print(t) 10 | else: 11 | print(t - d*(x-n)) -------------------------------------------------------------------------------- /LC-contest/atcoder/Beginner Contest 259/b.py: -------------------------------------------------------------------------------- 1 | """ 2 | B - Counterclockwise Rotation 3 | 将 (a,b) 逆时针循转 d度数 4 | """ 5 | import math 6 | a,b,d = map(int, input().split()) 7 | if a==b==0: 8 | print(0, 0); exit() 9 | if b>=0: 10 | angle = math.acos(a / math.sqrt(a*a + b*b)) 11 | else: 12 | angle = 2*math.pi - math.acos(a / math.sqrt(a*a + b*b)) 13 | angle += d*math.pi/180 14 | r = math.sqrt(a*a + b*b) 15 | print(r*math.cos(angle), r*math.sin(angle)) 16 | -------------------------------------------------------------------------------- /LC-contest/codeforce/#804 (Div. 2)/a.py: -------------------------------------------------------------------------------- 1 | """ A. The Third Three Number Problem 2 | 给定一个数字n, 要求找到三个非负数a,b,c, 是的` a^b+b^c+c^a == n` 3 | 思路1: #归纳 4 | 根据给的例子, 可以发现, 在每一bit中, 若三个数字中该比特为1的次数出现了0/3次则对结构不影响, 若出现了1/2次则在结果中计数两次. 5 | 因此, 可知n必然为偶数, 并且是a,b,c三个数中, 所谓出现1/2次的比特位所代表数字的2倍. 6 | 现在要求找出一种 a,b,c, 只需要将 n//2 的比特位分配到三个数字上即可, 一种简单的方法就是 `(n//2, 0, 0)` 7 | 8 | https://codeforces.com/contest/1699/problem/A 9 | """ 10 | t = int(input()) 11 | for i in range(t): 12 | n = int(input()) 13 | if n&1: 14 | print(-1); continue 15 | print(n//2, 0, 0) 16 | -------------------------------------------------------------------------------- /LC-contest/codeforce/#804 (Div. 2)/c.py: -------------------------------------------------------------------------------- 1 | """ C. The Third Problem 2 | 给定一个前n个自然数的排列p, 问在所有的排列中, 对于任意的数对 `(i,j)` 满足 `MEX(p[i...j]) = MEX(x[i...j])` 的所有排列有多少. 其中, MEX操作是找到数组中不存在的最小的自然数. 3 | 限制: n 1e5, 对于结果取模 4 | 5 | [4 0 3 2 1] 的结果是2, 包括: [4,0,3,2,1] and [4,0,2,3,1] 6 | [1 2 4 0 5 3] 的结果是4, 包括: [1,2,4,0,5,3]; [1,2,5,0,4,3]; [1,4,2,0,5,3]; [1,5,2,0,4,3]. 7 | 8 | https://codeforces.com/contest/1699/problem/C 9 | """ 10 | 11 | -------------------------------------------------------------------------------- /LC-contest/codeforce/131 (Rated for Div. 2)/a.py: -------------------------------------------------------------------------------- 1 | """ 2 | https://codeforces.com/contest/1701 3 | """ 4 | t = int(input()) 5 | for i in range(t): 6 | s = 0 7 | s += sum(map(int, input().split())) 8 | s += sum(map(int, input().split())) 9 | if s==0: print(0) 10 | elif s==4: print(2) 11 | else: print(1) -------------------------------------------------------------------------------- /LC-contest/codeforce/131 (Rated for Div. 2)/c.py: -------------------------------------------------------------------------------- 1 | """ C. Schedule Management 2 | 有n个员工和m各工作, 每个工作有适合的某一个员工, 对于匹配的工作需要1h, 非匹配需要2h. 每人一次只能做一个工作, 问最少完成的时间. 3 | 限制: m,n 2e5 4 | """ -------------------------------------------------------------------------------- /LC-contest/codeforce/131 (Rated for Div. 2)/d.py: -------------------------------------------------------------------------------- 1 | """ D. Permutation Restoration 2 | 对于1...n的排列a, 可以计算一个变换 `b[i] = i//a[i]`. 现在要根据b来还原a (任意合法的即可). 3 | 限制: n 5e5 4 | """ -------------------------------------------------------------------------------- /LC-contest/codeforce/131 (Rated for Div. 2)/e.py: -------------------------------------------------------------------------------- 1 | """ E. Text Editor 2 | 要将字符串s通过删除一些字符变为t, 初识时光标在最后. 合法的操作有: left; right; home; end; backspace. 其中backspace删除前一个字符, 若没有则没影响. 问最少操作次数 (不行的话返回-1) 3 | 限制: 两字符串长度 5e3 4 | 5 | """ -------------------------------------------------------------------------------- /LC-contest/codeforce/Codeforces Round #799 (Div. 4)/a.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | https://codeforces.com/contest/1692/problem/A 4 | """ 5 | 6 | n = int(input()) 7 | for _ in range(n): 8 | a, *other = map(int, input().split()) 9 | print(sum(i>a for i in other)) 10 | 11 | -------------------------------------------------------------------------------- /LC-contest/codeforce/Codeforces Round #799 (Div. 4)/b.py: -------------------------------------------------------------------------------- 1 | """ B. All Distinct """ 2 | def f(): 3 | n = int(input()) 4 | arr = map(int, input().split()) 5 | s = set(); cnt = 0 6 | for a in arr: 7 | if a not in s: s.add(a) 8 | else: cnt += 1 9 | c = cnt if cnt%2==0 else cnt+1 10 | print(n-c) 11 | 12 | n = int(input()) 13 | for _ in range(n): 14 | f() 15 | 16 | -------------------------------------------------------------------------------- /LC-contest/codeforce/Codeforces Round #799 (Div. 4)/input.txt: -------------------------------------------------------------------------------- 1 | https://codeforces.com/contest/1692/ 2 | Editorial: https://codeforces.com/blog/entry/103883 3 | 4 | 5 | # E 6 | 1 7 | 3 1 8 | 1 1 0 9 | 10 | 1 11 | 9 3 12 | 0 1 0 1 1 1 0 0 1 13 | 14 | # G 15 | 1 16 | 5 2 17 | 9 5 3 2 1 18 | 19 | # h 20 | 1 21 | 5 22 | 4 4 3 4 4 23 | -------------------------------------------------------------------------------- /LC-contest/codeforce/Codeforces Round #806 (Div. 4)/a.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for _ in range(n): 3 | print("YES" if input().strip().lower()=='yes' else "NO") 4 | 5 | -------------------------------------------------------------------------------- /LC-contest/codeforce/template/a.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | from functools import lru_cache 3 | @lru_cache(None) 4 | def f(): 5 | pass -------------------------------------------------------------------------------- /LC-contest/codeforce/template/c/c.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-contest/codeforce/template/c/c.py -------------------------------------------------------------------------------- /LC-contest/codeforce/template/d/d.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-contest/codeforce/template/d/d.py -------------------------------------------------------------------------------- /LC-contest/codeforce/template/input: -------------------------------------------------------------------------------- 1 | 1 2 | 00:00 1 -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1001/1001.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a,b; 6 | scanf("%d%d",&a,&b); 7 | printf("%d\n", a+b); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1001/1001.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int a,b; 9 | cin >> a >> b; 10 | cout << a+b << endl; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1001/1001.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a, b int 7 | fmt.Scanf("%d%d", &a, &b) 8 | fmt.Println(a+b) 9 | } -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1001/1001.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const data = fs.readFileSync('/dev/stdin') 3 | const result = data.toString('ascii').trim().split(' ').map(x => parseInt(x)).reduce((a, b) => a + b, 0) 4 | console.log(result) 5 | process.exit() // 请注意必须在出口点处加入此行 -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1001/1001.py: -------------------------------------------------------------------------------- 1 | s = input().split() 2 | print(int(s[0]) + int(s[1])) -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1014/1014.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // https://www.luogu.com.cn/blog/char32-t/solution-p1014 3 | int main() { 4 | int n, i=0, j=0;//前i条斜线一共j个数 5 | scanf("%d", &n); 6 | while(n>j) {//找到最小的i使得j>=n 7 | i++; 8 | j+=i; 9 | } 10 | if(i%2==1) 11 | printf("%d/%d",j-n+1,i+n-j);//i的奇偶决定着斜线上数的顺序,n是第i条斜线上倒数第j-n+1个数 12 | else 13 | printf("%d/%d",i+n-j,j-n+1);//若i是偶数,第i条斜线上倒数第i个元素是(i+1-i)/i 14 | return 0; 15 | } -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1035/1035.py: -------------------------------------------------------------------------------- 1 | """ P1035 [NOIP2002 普及组] 级数求和 #入门 2 | 对于调和级数 S(n) = 1 + 1/2 + 1/3 + ... + 1/n. 现给定一个整数k, 问 S(n) > k 的最小n. 3 | 限制: k<=15 4 | 思路1: #暴力 模拟 5 | 复杂度: 6 | 若按照naive的缩放, 对于因子 1/2, 不考虑首位的1, 可以通过 1,2,4,8.. 个元素之和得到, 这样的话时间复杂度约为 O(2^(2k)) 似乎不够 7 | 但实际上在 k=15 的时候答案在 1e7 级别 8 | 实际上, 按照欧拉推导过程, 调和级数之和的增长率为 e, 这样是符合要求的. 见 [here](https://www.luogu.com.cn/blog/Loner-Knowledge/Solutions-P1035) 9 | """ 10 | 11 | k = int(input()) 12 | s = 0; i = 1 13 | while s <= k: 14 | s += 1/i 15 | i += 1 16 | print(i-1) -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1046/1046.py: -------------------------------------------------------------------------------- 1 | """ P1046 [NOIP2005 普及组] 陶陶摘苹果 #入门 2 | 3 | """ 4 | s = map(int, input().split()) 5 | ava = int(input()) + 30 6 | print(sum(i<=ava for i in s)) -------------------------------------------------------------------------------- /LC-contest/luogu/1-入门/1304/1304.py: -------------------------------------------------------------------------------- 1 | """ P1304 哥德巴赫猜想 2 | 哥德巴赫猜想:任一大于 2 的偶数都可写成两个质数之和. 现在给定一个整数n, 写出 4,6,...n 的第一个因子最小的分解式 (例如10=3+7 而非 5+5). 3 | """ 4 | n = int(input()) 5 | primes = set([2]) 6 | for i in range(3, n): 7 | flag = True 8 | for p in primes: 9 | if i%p == 0: 10 | flag = False 11 | break 12 | if flag: 13 | primes.add(i) 14 | ps = sorted(primes) 15 | for i in range(4, n+1, 2): 16 | for p in ps: 17 | if i-p in primes: 18 | print(f"{i}={p}+{i-p}") 19 | break 20 | -------------------------------------------------------------------------------- /LC-contest/luogu/2-普及-/1003/1003.py: -------------------------------------------------------------------------------- 1 | """ P1003 [NOIP2011 提高组] 铺地毯 #普及- 2 | """ 3 | 4 | n = int(input()) 5 | record = [[0]*4 for _ in range(n)] 6 | for i in range(n): 7 | record[i] = list(map(int, input().split())) 8 | x,y = list(map(int, input().split())) 9 | ans = -1 10 | for i,(a,b,g,k) in enumerate(record): 11 | if a<=x<=a+g and b<=y<=b+k: 12 | ans = i+1 13 | print(ans) 14 | -------------------------------------------------------------------------------- /LC-contest/luogu/3-普及~提高-/1106/1106.py: -------------------------------------------------------------------------------- 1 | """ P1106 删数问题 2 | 给定一个正整数, 删去其中的k位, 要求结果最小. 3 | 约束: 位数不超过 250 4 | 思路1: #单调栈 5 | 从左往右遍历, 维护一个单调递增栈即可. 6 | 注意: 本题允许数字有前导零, 例如 20018 2 的答案为 1. 7 | """ 8 | 9 | nums = list(map(int, input().strip())) 10 | n = len(nums) 11 | k = int(input()) 12 | s = [] 13 | for num in nums: 14 | while s and s[-1]>num and k: 15 | # if num==0 and len(s)==1: break 16 | s.pop() 17 | k -= 1 18 | s.append(num) 19 | # 当k==0时, s[:-0] = [] 20 | s = s[:-k] if k else s 21 | # 注意到转一下int 22 | # 用例: 20018 2, 结果为1; 也即允许出现前导0 23 | print(int("".join(map(str, s)))) -------------------------------------------------------------------------------- /LC-contest/luogu/4-普及+~提高/1016/input: -------------------------------------------------------------------------------- 1 | 275.6 11.9 27.4 2.8 2 2 | 102.0 2.9 3 | 220.0 2.2 -------------------------------------------------------------------------------- /LC-contest/luogu/5-提高+~省选-/P4513 小白逛公园/P4513_2.out: -------------------------------------------------------------------------------- 1 | 1252 2 | 1252 3 | 798 4 | 1641 5 | 1547 6 | 2062 7 | 2880 8 | 1967 9 | 3628 10 | 1533 11 | 650 12 | 4955 13 | 1742 14 | 1701 15 | 5776 16 | 1349 17 | 456 18 | 741 19 | 5470 20 | 5805 21 | 5425 22 | 5859 23 | 1243 24 | 5425 25 | 5425 26 | 5642 27 | 3724 28 | -302 29 | 3162 30 | 3103 31 | 2392 32 | 2706 33 | 4343 34 | 1689 35 | 2897 36 | 2598 37 | 5873 38 | 3789 39 | 1478 40 | 1653 41 | -474 42 | 5905 43 | -834 44 | -908 45 | -702 46 | -994 47 | -883 48 | -834 49 | -702 50 | -702 51 | -883 52 | -702 53 | -702 54 | -702 55 | -702 56 | -702 57 | -702 58 | -------------------------------------------------------------------------------- /LC-contest/luogu/README.md: -------------------------------------------------------------------------------- 1 | 洛谷: 2 | 3 | 目前在刷主题库中... 4 | -------------------------------------------------------------------------------- /LC-contest/misc/22hulu.py: -------------------------------------------------------------------------------- 1 | """ 2 | 有N个技能, 每个技能等级有K种. 技能所需的点数和收益分别为 cost[i][j], power[i][j]. 问在T个技能点约束下的最大收益. 3 | 限制: N 1e3, K 1e2, 总点数T 1e5. 技能点花费最多 20, 收益最多 1e4. 4 | 注意技能的划分和收益是累积的: 也即 cost[i][j] 即可学到第i个技能的j等级, 收益只算 power[i][j]. 5 | """ -------------------------------------------------------------------------------- /LC-contest/record-contest.md: -------------------------------------------------------------------------------- 1 | todo 2 | 3 | - 回顾周赛: 更新题目编号. 整理更好的题解 (灵神 等) 4 | - 进度: 5 | - 周赛 310 6 | - 双周赛: d88 7 | - todo: d89; 315 8 | -------------------------------------------------------------------------------- /LC-go/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "go.inferGopath": false 3 | } 4 | -------------------------------------------------------------------------------- /LC-go/00-base/algorithms.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | // ================ 二分搜索 ========== 9 | // sort.SearchInts 10 | // 参见 sort.Search 函数 11 | func testSearchInts(){ 12 | d := []int{1,3,6,6,7,9,4,10,5,6} 13 | idx := sort.SearchInts(d, 6) 14 | fmt.Println(idx) // 2, 改成搜索 4也是返回2; 即应该插入的元素位置. 15 | 16 | } 17 | func main(){ 18 | testSearchInts() 19 | } 20 | -------------------------------------------------------------------------------- /LC-go/structures/NestedInterger_test.go: -------------------------------------------------------------------------------- 1 | package structures 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func Test_NestedInteger(t *testing.T) { 10 | ast := assert.New(t) 11 | 12 | n := NestedInteger{} 13 | 14 | ast.True(n.IsInteger()) 15 | 16 | n.SetInteger(1) 17 | ast.Equal(1, n.GetInteger()) 18 | 19 | elem := NestedInteger{Num: 1} 20 | 21 | expected := NestedInteger{ 22 | Num: 1, 23 | Ns: []*NestedInteger{&elem}, 24 | } 25 | n.Add(elem) 26 | 27 | ast.Equal(expected, n) 28 | 29 | ast.Equal(expected.Ns, n.GetList()) 30 | } 31 | -------------------------------------------------------------------------------- /LC-go/structures/Queue_test.go: -------------------------------------------------------------------------------- 1 | package structures 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func Test_Queue(t *testing.T) { 10 | ast := assert.New(t) 11 | 12 | q := NewQueue() 13 | ast.True(q.IsEmpty(), "检查新建的 q 是否为空") 14 | 15 | start, end := 0, 100 16 | 17 | for i := start; i < end; i++ { 18 | q.Push(i) 19 | ast.Equal(i-start+1, q.Len(), "Push 后检查 q 的长度。") 20 | } 21 | 22 | for i := start; i < end; i++ { 23 | ast.Equal(i, q.Pop(), "从 q 中 pop 出数来。") 24 | } 25 | 26 | ast.True(q.IsEmpty(), "检查 Pop 完毕后的 q 是否为空") 27 | } 28 | -------------------------------------------------------------------------------- /LC-go/structures/Stack_test.go: -------------------------------------------------------------------------------- 1 | package structures 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func Test_Stack(t *testing.T) { 10 | ast := assert.New(t) 11 | 12 | s := NewStack() 13 | ast.True(s.IsEmpty(), "检查新建的 s 是否为空") 14 | 15 | start, end := 0, 100 16 | 17 | for i := start; i < end; i++ { 18 | s.Push(i) 19 | ast.Equal(i-start+1, s.Len(), "Push 后检查 q 的长度。") 20 | } 21 | 22 | for i := end - 1; i >= start; i-- { 23 | ast.Equal(i, s.Pop(), "从 s 中 pop 出数来。") 24 | } 25 | 26 | ast.True(s.IsEmpty(), "检查 Pop 完毕后的 s 是否为空") 27 | } 28 | -------------------------------------------------------------------------------- /LC-go/useful-codes.md: -------------------------------------------------------------------------------- 1 | ### fmt 2 | 3 | ```go 4 | fmt.Sprintf("%d:%02d", 2, 8) 5 | ``` 6 | 7 | ### bits 8 | 9 | ```go 10 | bits.OnesCount(uint(i)) 11 | ``` 12 | 13 | ### sort 14 | 15 | ```go 16 | 17 | ``` 18 | 19 | ### math 20 | 21 | ```go 22 | math.MinInt32 23 | ``` 24 | -------------------------------------------------------------------------------- /LC-notes/Leetcode-first-100.md: -------------------------------------------------------------------------------- 1 | 2 | 准备重新用 Go写一下LC前100题, 一是整理复习题型, 二是学习Go的写法. 3 | 4 | - 灵神的Go实现: 5 | - halfrost的代码: 6 | -------------------------------------------------------------------------------- /LC-notes/media/16057577754268/16057581777903.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16057577754268/16057581777903.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16147419822017.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16147419822017.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16147420077589.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16147420077589.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16147462117985.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16147462117985.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16147508756483.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16147508756483.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16149076152534.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16149076152534.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16150005177904.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16150005177904.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16150045759234.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16150045759234.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16150104215412.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16150104215412.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16150105404456.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16150105404456.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16150459126250.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16150459126250.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16150864008703.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16150864008703.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16150882727746.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16150882727746.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16151688033551.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16151688033551.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16151693202715.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16151693202715.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16151766304739.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16151766304739.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16153075223021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16153075223021.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16153887376582.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16153887376582.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16153908549608.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16153908549608.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16154269940737.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16154269940737.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16154270505502.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16154270505502.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16154272302558.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16154272302558.jpg -------------------------------------------------------------------------------- /LC-notes/media/16147360600817/16155651378139.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/LC-notes/media/16147360600817/16155651378139.jpg -------------------------------------------------------------------------------- /Mathematica/.gitignore: -------------------------------------------------------------------------------- 1 | book/ 2 | Mathematica及其应用/ 3 | notebooks/ -------------------------------------------------------------------------------- /algorithm-ds-templates/Basic-算法基础/Sort-排序/heapSort.py: -------------------------------------------------------------------------------- 1 | import heapq 2 | 3 | """ 堆排序 4 | 1. 建立一个堆; 5 | 2. 每次从堆中取出最大的元素; 6 | """ 7 | 8 | def heap_sort(lst): 9 | heapq.heapify(lst) 10 | return [heapq.heappop(lst) for i in range(len(lst))] 11 | 12 | data = [1,5,3,2,8,5] 13 | print(data) 14 | print(heap_sort(data)) 15 | 16 | -------------------------------------------------------------------------------- /algorithm-ds-templates/DP-动态规划/Knapsack-背包/01bag-template.py: -------------------------------------------------------------------------------- 1 | from easonsi import utils 2 | from easonsi.util.leetcode import * 3 | from functools import cache 4 | 5 | """ 6 | w[i]: 第i个物品的体积 7 | v[i]: 第i个物品的价值 8 | 返回: 不超过capacity的前提下, 能够获得的最大价值 9 | """ 10 | def zero_one_knapsack(capacity, w, v): 11 | n = len(w) 12 | @cache 13 | def dfs(i,c): 14 | if i<0: return 0 15 | if c 4 | 5 | 关键是「部分匹配表/失配函数」, 也即匹配失败之后下一个要匹配的位置. 6 | 7 | - 部分匹配表,又称为失配函数,作用是让算法无需多次匹配S中的任何字符。能够实现线性时间搜索的关键是在主串的一些字段中检查模式串的初始字段,可以确切地知道在当前位置之前的一个潜在匹配的位置。换句话说,在不错过任何潜在匹配的情况下,"预搜索"这个模式串本身并将其译成一个包含所有可能失配的位置对应可以绕过最多无效字符的列表。 8 | - 例如, 对于 aaa, 字符串的前缀函数应该是 `pi=[0,1,2]`, 定义为 s[0...i] 的 真前缀和后缀相等的最大长度 (显然 pi[0]=0) 9 | - 而其 `nxt=[-1,0,1]`, 这是为了和编程语言中数组从0开始index保持一致. 例如当要匹配第2个元素时, 若失败, 可知 s[0...2] 的前缀函数值为2 10 | - 在下面的 search函数中, 遍历的j表示当前匹配到了字符串a的多少长度 11 | -------------------------------------------------------------------------------- /cpp/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.errorSquiggles": "Disabled" 3 | } -------------------------------------------------------------------------------- /cpp/cpp-hackerrank/basic/1-hello-world.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 计划: https://www.hackerrank.com/domains/cpp?filters%5Bskills%5D%5B%5D=C%2B%2B%20%28Basic%29 3 | 4 | 5 | */ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | int main() { 12 | // printf("Hello, World!"); 13 | cout << "Hello," << " World!\n"; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/cpp-hackerrank/basic/2-basic-datatype.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Int ("%d"): 32 Bit integer 3 | Long ("%ld"): 64 bit integer 4 | Char ("%c"): Character type 5 | Float ("%f"): 32 bit real value 6 | Double ("%lf"): 64 bit real value 7 | */ 8 | 9 | #include 10 | #include 11 | using namespace std; 12 | 13 | int main() { 14 | // Complete the code. 15 | int a; 16 | long b; 17 | char c; 18 | float d; 19 | double e; 20 | scanf("%d %ld %c %f %lf", &a, &b, &c, &d, &e); 21 | printf("%d\n%ld\n%c\n%f\n%lf", a,b,c,d,e); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /cpp/cpp-hackerrank/basic/io-scanf-printf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 主要参见 https://www.hackerrank.com/domains/cpp 3 | */ 4 | 5 | #include 6 | #include 7 | // #include 8 | using namespace std; 9 | 10 | /* 11 | 3 12345678912345 a 334.23 14049.30493 12 | */ 13 | int main() { 14 | // Complete the code. 15 | int a; 16 | long b; 17 | char c; 18 | float d; 19 | double e; 20 | scanf("%d %ld %c %f %lf", &a, &b, &c, &d, &e); 21 | printf("%d\n%ld\n%c\n%f\n%lf", a,b,c,d,e); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /cpp/cpp-hackerrank/helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "Hello World" << std::endl; 6 | std::cout << "Hello World Again" << std::endl; 7 | } 8 | -------------------------------------------------------------------------------- /cpp/cpp-leatcode/makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | CPPFLAGS= -Wno-deprecated -std=c++11 -O3 -m64 -c -w #-Wall 3 | LDFLAGS = -O3 -m64 4 | SOURCES = 2207.cpp 5 | OBJECTS = $(SOURCES:.cpp=.o) 6 | EXECUTABLE=2207 7 | 8 | all: $(SOURCES) $(EXECUTABLE) 9 | 10 | $(EXECUTABLE) : $(OBJECTS) 11 | $(CC) $(LDFLAGS) $@.o -o $@ 12 | 13 | .cpp.o : 14 | $(CC) $(CPPFLAGS) $< -o $@ 15 | 16 | clean: 17 | rm -f *.o 18 | -------------------------------------------------------------------------------- /cpp/cpp-leatcode/run.sh: -------------------------------------------------------------------------------- 1 | make 2 | make clean 3 | ./2207 4 | -------------------------------------------------------------------------------- /cpp/learn-STL/350-stack.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | void test1(){ 7 | stack s; 8 | s.push(1); 9 | s.push(2); 10 | s.push(3); 11 | 12 | while (!s.empty()) { 13 | //输出栈顶元素 14 | cout << "栈顶元素为: " << s.top() << endl; 15 | //弹出栈顶元素 16 | s.pop(); 17 | } 18 | cout << "栈的大小为:" << s.size() << endl; 19 | } 20 | 21 | int main(){ 22 | test1(); 23 | } -------------------------------------------------------------------------------- /cpp/learn-STL/stl.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/cpp/learn-STL/stl.md -------------------------------------------------------------------------------- /cpp/learn-cpp-basic/makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | CPPFLAGS= -Wno-deprecated -std=c++11 -O3 -m64 -c -w #-Wall 3 | LDFLAGS = -O3 -m64 4 | SOURCES = tmp.cpp 5 | OBJECTS = $(SOURCES:.cpp=.o) 6 | EXECUTABLE=a.out 7 | 8 | all: $(SOURCES) $(EXECUTABLE) 9 | 10 | $(EXECUTABLE) : $(OBJECTS) 11 | $(CC) $(LDFLAGS) $^ -o $@ 12 | 13 | .cpp.o : 14 | $(CC) $(CPPFLAGS) $< -o $@ 15 | 16 | clean: 17 | rm -f *.o 18 | -------------------------------------------------------------------------------- /cpp/learn-cpp-basic/run.sh: -------------------------------------------------------------------------------- 1 | make 2 | make clean 3 | ./a.out -------------------------------------------------------------------------------- /cpp/learn-cpp-basic/tmp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | //定义结构体 Student 3 | struct Student{ 4 | //结构体包含的成员变量 5 | char *name; 6 | int age; 7 | float score; 8 | }; 9 | //显示结构体的成员变量 10 | void display(Student stu){ 11 | printf("%s的年龄是 %d,成绩是 %f\n", stu.name, stu.age, stu.score); 12 | } 13 | int main(){ 14 | struct Student stu1; 15 | //为结构体的成员变量赋值 16 | stu1.name = "小明"; 17 | stu1.age = 15; 18 | stu1.score = 92.5; 19 | //调用函数 20 | display(stu1); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /cpp/learn-cpp-heima/135-template-class-inhertance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | template 6 | class Base { 7 | T m; 8 | }; 9 | 10 | //class Son:public Base //错误,c++编译需要给子类分配内存,必须知道父类中T的类型 11 | class Son : public Base {//必须指定一个类型 12 | 13 | }; 14 | 15 | template 16 | class Son2 : public Base { 17 | public: 18 | Son2() { 19 | cout << typeid(T1).name() << endl; 20 | cout << typeid(T2).name() << endl; 21 | 22 | } 23 | }; 24 | 25 | int main () { 26 | // Son a; 27 | 28 | Son2 a; 29 | } -------------------------------------------------------------------------------- /cpp/learn-cpp-heima/137-name.cpp: -------------------------------------------------------------------------------- 1 | #include "137-name.h" 2 | 3 | 4 | //构造函数 类外实现 5 | template 6 | Person::Person(T1 name, T2 age) { 7 | this->m_Name = name; 8 | this->m_Age = age; 9 | } 10 | 11 | //成员函数 类外实现 12 | template 13 | void Person::showPerson() { 14 | cout << "姓名: " << this->m_Name << " 年龄:" << this->m_Age << endl; 15 | } -------------------------------------------------------------------------------- /cpp/learn-cpp-heima/137-name.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | using namespace std; 4 | #include 5 | 6 | template 7 | class Person { 8 | public: 9 | Person(T1 name, T2 age); 10 | void showPerson(); 11 | public: 12 | T1 m_Name; 13 | T2 m_Age; 14 | }; 15 | -------------------------------------------------------------------------------- /cpp/learn-cpp-heima/137-template-class-split-file.cpp: -------------------------------------------------------------------------------- 1 | //解决方式1,包含cpp源文件 2 | // #include "137-name.cpp" 3 | 4 | //解决方式2,将声明和实现写到一起,文件后缀名改为.hpp 5 | #include "137-name.hpp" 6 | 7 | int main() { 8 | Person p("Tommy", 10); 9 | p.showPerson(); 10 | } -------------------------------------------------------------------------------- /cpp/learn-cpp-heima/468-rect-inderitance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Animal{ 5 | public: 6 | int m_Age; 7 | }; 8 | 9 | //继承前加virtual关键字后,变为虚继承 10 | //此时公共的父类Animal称为虚基类 11 | class Sheep: public virtual Animal{}; 12 | class Tuo: virtual public Animal{}; 13 | 14 | class SheepTuo: public Sheep, public Tuo{}; 15 | 16 | 17 | int main() { 18 | SheepTuo st; 19 | st.Sheep::m_Age = 25; 20 | st.Tuo::m_Age = 28; 21 | cout << sizeof(st) << endl; 22 | cout << st.Sheep::m_Age << st.Tuo::Tuo::m_Age << st.m_Age << endl; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cpp/learn-cpp-heima/person.txt: -------------------------------------------------------------------------------- 1 | 张三" -------------------------------------------------------------------------------- /cpp/learn-cpp-heima/readme.md: -------------------------------------------------------------------------------- 1 | - bilibili [黑马程序员](https://www.bilibili.com/video/BV1et411b73Z); [材料](https://pan.baidu.com/s/1vTXgoXql0JZIuThKIMJJCA?pwd=1234) 2 | 3 | -------------------------------------------------------------------------------- /cpp/learn-cpp-heima/test.txt: -------------------------------------------------------------------------------- 1 | name: zhangsan 2 | name: zhangsan 3 | name: zhangsan 4 | -------------------------------------------------------------------------------- /cpp/make/01-single-src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int count, char **args) { 4 | printf("hello world!\n"); 5 | return 0; 6 | } -------------------------------------------------------------------------------- /cpp/make/01-single-src/makefile: -------------------------------------------------------------------------------- 1 | # 变量定义 2 | app_name = app 3 | clean_cmd = rm app *.o 4 | COPTIONS = -c -o 5 | 6 | # 使用变量: ${variable name} 7 | all: ${app_name} 8 | 9 | app: app.o 10 | gcc -o $@ $< 11 | 12 | app.o: main.c 13 | gcc $(COPTIONS) $@ $^ 14 | 15 | # 2. 使用变量: $(variable name) 16 | clean: 17 | $(clean_cmd) 18 | 19 | run: 20 | ./app -------------------------------------------------------------------------------- /cpp/make/01-single-src/makefile.v1: -------------------------------------------------------------------------------- 1 | all: app 2 | 3 | app: app.o 4 | gcc -o app app.o 5 | 6 | app.o: main.c 7 | gcc -c -o app.o main.c 8 | 9 | clean: 10 | rm app *o 11 | 12 | run: 13 | ./app 14 | 15 | -------------------------------------------------------------------------------- /cpp/misc/base/01-basic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // 用下面的形式来控制运行 6 | #if 0 7 | cout << "hi"; 8 | #else 9 | cout << "hello"; 10 | #endif 11 | return 0; 12 | } -------------------------------------------------------------------------------- /cpp/misc/base/03-const.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // 下面的三个字符串字面量一致 6 | string s = "hello, \ 7 | dear"; 8 | s = "hello, " "d" "ear"; 9 | s = "hello, dear"; 10 | cout << s < 2 | 3 | // 函数声明 4 | void func(void); 5 | 6 | static int count = 10; /* 全局变量 */ 7 | 8 | int main() 9 | { 10 | while(count--) 11 | { 12 | func(); 13 | } 14 | return 0; 15 | } 16 | // 函数定义 17 | void func( void ) 18 | { 19 | static int i = 5; // 局部静态变量 20 | i++; 21 | std::cout << "变量 i 为 " << i ; 22 | std::cout << " , 变量 count 为 " << count << std::endl; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /cpp/misc/base/06-guess-number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | srand((unsigned int)time(NULL)); // 随机种子 8 | int num = rand()%100 + 1; 9 | int val; 10 | 11 | while (1){ 12 | cin >> val; 13 | if (val > num){ 14 | cout << "Too big." << endl; 15 | } else if (val < num) { 16 | cout << "Too small." << endl; 17 | } else { 18 | cout << "You've got it, the num is " << num << endl; 19 | break; 20 | } 21 | } 22 | 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /cpp/misc/base/09-pointer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAX = 3; 6 | int main (){ 7 | int var[MAX] = {10, 100, 200}; 8 | int * ptr; 9 | 10 | cout << var[MAX-1]<< endl; 11 | 12 | ptr = &var[MAX-1]; 13 | printf("ptr: %p value: %i\n", ptr, *ptr); 14 | ptr = var; 15 | printf("ptr: %p value: %i\n", ptr, *ptr); 16 | 17 | } -------------------------------------------------------------------------------- /cpp/misc/base/11-passing-pointer-to-func.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | void getSeconds(int *par) 7 | { 8 | // 获取当前的秒数 9 | *par = time( NULL ); 10 | return; 11 | } 12 | 13 | int main () 14 | { 15 | int sec; 16 | 17 | 18 | getSeconds( &sec ); 19 | 20 | long a = sec; 21 | short b = sec; 22 | 23 | // 输出实际值 24 | cout << "Number of seconds :" << sec << "\t" << b << endl; 25 | 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /cpp/misc/base/helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | std::cout << "hello, world" << endl; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /cpp/misc/base/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int count ; 4 | extern void write_extern(); 5 | 6 | 7 | 8 | int main() 9 | { 10 | 11 | 12 | count = 5; 13 | write_extern(); 14 | } -------------------------------------------------------------------------------- /cpp/misc/helloworld/helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | std::cout << "hello, world\n"; 4 | return 0; 5 | } -------------------------------------------------------------------------------- /cpp/pj2-manage-system/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ```bash 4 | g++ main.cpp workerManager.cpp -include workerManager.h #测试 showMenu() 5 | g++ main.cpp -include worker.h -include employee.h -include manager.h -include boss.h employee.cpp managerr.cpp boss.cpp #test() 测试职工抽象类。#include "worderManager.h" 虽然写了但没用到的情况下编译不引入也没问题 6 | g++ main.cpp -include worker.h -include employee.h -include manager.h -include boss.h employee.cpp managerr.cpp boss.cpp -include workerManager.h workerManager.cpp 7 | ``` -------------------------------------------------------------------------------- /cpp/pj2-manage-system/boss.cpp: -------------------------------------------------------------------------------- 1 | #include "boss.h" 2 | 3 | Boss::Boss(int id, string name, int dId) { 4 | this->m_Name = name; 5 | this->m_Id = id; 6 | this->m_DeptId = dId; 7 | } 8 | 9 | void Boss::showInfo(){ 10 | cout << "Id: " << this->m_Id 11 | << "\tName: " << this->m_Name 12 | << "\tDeptId: " << this->getDeptName() << endl; 13 | } 14 | 15 | string Boss::getDeptName() { 16 | return "boss"; 17 | } -------------------------------------------------------------------------------- /cpp/pj2-manage-system/boss.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | using namespace std; 4 | #include "worker.h" 5 | 6 | class Boss : public Worker { 7 | public: 8 | Boss(int id, string name, int dId); 9 | virtual void showInfo(); 10 | virtual string getDeptName(); 11 | }; -------------------------------------------------------------------------------- /cpp/pj2-manage-system/empFile.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/cpp/pj2-manage-system/empFile.txt -------------------------------------------------------------------------------- /cpp/pj2-manage-system/employee.cpp: -------------------------------------------------------------------------------- 1 | #include "employee.h" 2 | 3 | Employee::Employee(int id, string name, int dId) { 4 | this->m_Name = name; 5 | this->m_Id = id; 6 | this->m_DeptId = dId; 7 | } 8 | 9 | void Employee::showInfo(){ 10 | cout << "Id: " << this->m_Id 11 | << "\tName: " << this->m_Name 12 | << "\tDeptId: " << this->getDeptName() << endl; 13 | } 14 | 15 | string Employee::getDeptName() { 16 | return "employee"; 17 | } -------------------------------------------------------------------------------- /cpp/pj2-manage-system/employee.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | using namespace std; 4 | #include "worker.h" 5 | 6 | class Employee : public Worker { 7 | public: 8 | Employee(int id, string name, int dId); 9 | virtual void showInfo(); 10 | virtual string getDeptName(); 11 | }; -------------------------------------------------------------------------------- /cpp/pj2-manage-system/manager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | using namespace std; 4 | #include "worker.h" 5 | 6 | class Manager : public Worker { 7 | public: 8 | Manager(int id, string name, int dId); 9 | virtual void showInfo(); 10 | virtual string getDeptName(); 11 | }; -------------------------------------------------------------------------------- /cpp/pj2-manage-system/managerr.cpp: -------------------------------------------------------------------------------- 1 | #include "manager.h" 2 | 3 | Manager::Manager(int id, string name, int dId) { 4 | this->m_Name = name; 5 | this->m_Id = id; 6 | this->m_DeptId = dId; 7 | } 8 | 9 | void Manager::showInfo(){ 10 | cout << "Id: " << this->m_Id 11 | << "\tName: " << this->m_Name 12 | << "\tDeptId: " << this->getDeptName() << endl; 13 | } 14 | 15 | string Manager::getDeptName() { 16 | return "manager"; 17 | } -------------------------------------------------------------------------------- /cpp/pj2-manage-system/worker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | using namespace std; 4 | 5 | class Worker{ 6 | public: 7 | virtual ~Worker(){}; 8 | // 想要 delete 的时候警告 warning: delete called on 'Worker' that is abstract but has non-virtual destructor 9 | // 添加了 vitual 的析构函数后正常。 10 | // 并且只能是 virtual 的 11 | virtual void showInfo() = 0; 12 | virtual string getDeptName() = 0; 13 | int m_Id; 14 | string m_Name; 15 | int m_DeptId; 16 | }; -------------------------------------------------------------------------------- /cpp/test/t-array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | 7 | int main() { 8 | 9 | array arr; 10 | //初始化 values2 为{10,11,12,13,14} 11 | int initvalue = 10; 12 | // 通过引用的方式赋值 13 | for (auto& value : arr) { 14 | value = initvalue; 15 | initvalue++; 16 | } 17 | cout << "Values1 is : "; 18 | for (auto i = arr.begin(); i < arr.end(); i++) { 19 | cout << *i << " "; 20 | } 21 | } -------------------------------------------------------------------------------- /cpp/test/t-struct: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/cpp/test/t-struct -------------------------------------------------------------------------------- /go/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "go.inferGopath": false 3 | } -------------------------------------------------------------------------------- /go/learn-go/go.mod: -------------------------------------------------------------------------------- 1 | module go.learn.note 2 | 3 | go 1.16 4 | 5 | require gopl.io v0.0.0 6 | replace gopl.io => ../z-gopl 7 | -------------------------------------------------------------------------------- /go/learn-go/misc/slice.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // func main(){ 6 | // s1 := make([]int, 4, 32) 7 | // fmt.Println(len(s1), cap(s1)) 8 | // var s2 []int 9 | // fmt.Println("var: ", len(s2), cap(s2)) 10 | // } 11 | 12 | func main() { 13 | fmt.Println("Let's go!") 14 | } 15 | -------------------------------------------------------------------------------- /go/learn-go/misc/string.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/go/learn-go/misc/string.go -------------------------------------------------------------------------------- /go/learn-go/test-gopl/ch4/4-1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // https://yar999.gitbook.io/gopl-zh/ch4/ch4-01 4 | 5 | import ( 6 | "fmt" 7 | // "popcount" 8 | "math/bits" 9 | // 不知道怎么引用 10 | // "github.com/tmthrgd/go-popcount" 11 | ) 12 | 13 | func testCount() { 14 | // c := popcount.CountBytes([]int{2, 3}) 15 | c := bits.OnesCount(3) 16 | fmt.Println(c) 17 | 18 | // c = popcount.CountBytes8(3) 19 | // fmt.Print(c) 20 | } 21 | 22 | func main() { 23 | testCount() 24 | } 25 | -------------------------------------------------------------------------------- /go/z-gopl/CNAME: -------------------------------------------------------------------------------- 1 | gopl.io 2 | -------------------------------------------------------------------------------- /go/z-gopl/ch1/echo1/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 4. 5 | //!+ 6 | 7 | // Echo1 prints its command-line arguments. 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | "os" 13 | ) 14 | 15 | func main() { 16 | var s, sep string 17 | for i := 1; i < len(os.Args); i++ { 18 | s += sep + os.Args[i] 19 | sep = " " 20 | } 21 | fmt.Println(s) 22 | } 23 | 24 | //!- 25 | -------------------------------------------------------------------------------- /go/z-gopl/ch1/echo2/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 6. 5 | //!+ 6 | 7 | // Echo2 prints its command-line arguments. 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | "os" 13 | ) 14 | 15 | func main() { 16 | s, sep := "", "" 17 | for _, arg := range os.Args[1:] { 18 | s += sep + arg 19 | sep = " " 20 | } 21 | fmt.Println(s) 22 | } 23 | 24 | //!- 25 | -------------------------------------------------------------------------------- /go/z-gopl/ch1/echo3/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 8. 5 | 6 | // Echo3 prints its command-line arguments. 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "strings" 13 | ) 14 | 15 | //!+ 16 | func main() { 17 | fmt.Println(strings.Join(os.Args[1:], " ")) 18 | } 19 | 20 | //!- 21 | -------------------------------------------------------------------------------- /go/z-gopl/ch1/helloworld/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 1. 5 | 6 | // Helloworld is our first Go program. 7 | //!+ 8 | package main 9 | 10 | import "fmt" 11 | 12 | func main() { 13 | fmt.Println("Hello, 世界") 14 | } 15 | 16 | //!- 17 | -------------------------------------------------------------------------------- /go/z-gopl/ch10/cross/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 295. 5 | 6 | // The cross command prints the values of GOOS and GOARCH for this target. 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "runtime" 12 | ) 13 | 14 | //!+ 15 | func main() { 16 | fmt.Println(runtime.GOOS, runtime.GOARCH) 17 | } 18 | 19 | //!- 20 | -------------------------------------------------------------------------------- /go/z-gopl/ch11/word1/word.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 303. 5 | //!+ 6 | 7 | // Package word provides utilities for word games. 8 | package word 9 | 10 | // IsPalindrome reports whether s reads the same forward and backward. 11 | // (Our first attempt.) 12 | func IsPalindrome(s string) bool { 13 | for i := range s { 14 | if s[i] != s[len(s)-1-i] { 15 | return false 16 | } 17 | } 18 | return true 19 | } 20 | 21 | //!- 22 | -------------------------------------------------------------------------------- /go/z-gopl/ch2/boiling/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 29. 5 | //!+ 6 | 7 | // Boiling prints the boiling point of water. 8 | package main 9 | 10 | import "fmt" 11 | 12 | const boilingF = 212.0 13 | 14 | func main() { 15 | var f = boilingF 16 | var c = (f - 32) * 5 / 9 17 | fmt.Printf("boiling point = %g°F or %g°C\n", f, c) 18 | // Output: 19 | // boiling point = 212°F or 100°C 20 | } 21 | 22 | //!- 23 | -------------------------------------------------------------------------------- /go/z-gopl/ch2/echo4/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 33. 5 | //!+ 6 | 7 | // Echo4 prints its command-line arguments. 8 | package main 9 | 10 | import ( 11 | "flag" 12 | "fmt" 13 | "strings" 14 | ) 15 | 16 | var n = flag.Bool("n", false, "omit trailing newline") 17 | var sep = flag.String("s", " ", "separator") 18 | 19 | func main() { 20 | flag.Parse() 21 | fmt.Print(strings.Join(flag.Args(), *sep)) 22 | if !*n { 23 | fmt.Println() 24 | } 25 | } 26 | 27 | //!- 28 | -------------------------------------------------------------------------------- /go/z-gopl/ch2/tempconv/conv.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 41. 5 | 6 | //!+ 7 | 8 | package tempconv 9 | 10 | // CToF converts a Celsius temperature to Fahrenheit. 11 | func CToF(c Celsius) Fahrenheit { return Fahrenheit(c*9/5 + 32) } 12 | 13 | // FToC converts a Fahrenheit temperature to Celsius. 14 | func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) } 15 | 16 | //!- 17 | -------------------------------------------------------------------------------- /go/z-gopl/ch4/treesort/sort_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | package treesort_test 5 | 6 | import ( 7 | "fmt" 8 | "math/rand" 9 | "sort" 10 | "testing" 11 | 12 | "gopl.io/ch4/treesort" 13 | ) 14 | 15 | func TestSort(t *testing.T) { 16 | data := make([]int, 50) 17 | for i := range data { 18 | data[i] = rand.Int() % 50 19 | } 20 | treesort.Sort(data) 21 | fmt.Println(data) 22 | if !sort.IntsAreSorted(data) { 23 | t.Errorf("not sorted: %v", data) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /go/z-gopl/ch7/sleep/sleep.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 179. 5 | 6 | // The sleep program sleeps for a specified period of time. 7 | package main 8 | 9 | import ( 10 | "flag" 11 | "fmt" 12 | "time" 13 | ) 14 | 15 | //!+sleep 16 | var period = flag.Duration("period", 1*time.Second, "sleep period") 17 | 18 | func main() { 19 | flag.Parse() 20 | fmt.Printf("Sleeping for %v...", *period) 21 | time.Sleep(*period) 22 | fmt.Println() 23 | } 24 | 25 | //!-sleep 26 | -------------------------------------------------------------------------------- /go/z-gopl/ch7/tempflag/tempflag.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // See page 181. 5 | 6 | // Tempflag prints the value of its -temp (temperature) flag. 7 | package main 8 | 9 | import ( 10 | "flag" 11 | "fmt" 12 | 13 | "gopl.io/ch7/tempconv" 14 | ) 15 | 16 | //!+ 17 | var temp = tempconv.CelsiusFlag("temp", 20.0, "the temperature") 18 | 19 | func main() { 20 | flag.Parse() 21 | fmt.Println(*temp) 22 | } 23 | 24 | //!- 25 | -------------------------------------------------------------------------------- /go/z-gopl/ch9/memo2/memo_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | package memo_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "gopl.io/ch9/memo2" 10 | "gopl.io/ch9/memotest" 11 | ) 12 | 13 | var httpGetBody = memotest.HTTPGetBody 14 | 15 | func Test(t *testing.T) { 16 | m := memo.New(httpGetBody) 17 | memotest.Sequential(t, m) 18 | } 19 | 20 | func TestConcurrent(t *testing.T) { 21 | m := memo.New(httpGetBody) 22 | memotest.Concurrent(t, m) 23 | } 24 | -------------------------------------------------------------------------------- /go/z-gopl/ch9/memo3/memo_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | package memo_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "gopl.io/ch9/memo3" 10 | "gopl.io/ch9/memotest" 11 | ) 12 | 13 | var httpGetBody = memotest.HTTPGetBody 14 | 15 | func Test(t *testing.T) { 16 | m := memo.New(httpGetBody) 17 | memotest.Sequential(t, m) 18 | } 19 | 20 | func TestConcurrent(t *testing.T) { 21 | m := memo.New(httpGetBody) 22 | memotest.Concurrent(t, m) 23 | } 24 | -------------------------------------------------------------------------------- /go/z-gopl/ch9/memo4/memo_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | package memo_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "gopl.io/ch9/memo4" 10 | "gopl.io/ch9/memotest" 11 | ) 12 | 13 | var httpGetBody = memotest.HTTPGetBody 14 | 15 | func Test(t *testing.T) { 16 | m := memo.New(httpGetBody) 17 | memotest.Sequential(t, m) 18 | } 19 | 20 | func TestConcurrent(t *testing.T) { 21 | m := memo.New(httpGetBody) 22 | memotest.Concurrent(t, m) 23 | } 24 | -------------------------------------------------------------------------------- /go/z-gopl/ch9/memo5/memo_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | package memo_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "gopl.io/ch9/memo5" 10 | "gopl.io/ch9/memotest" 11 | ) 12 | 13 | var httpGetBody = memotest.HTTPGetBody 14 | 15 | func Test(t *testing.T) { 16 | m := memo.New(httpGetBody) 17 | defer m.Close() 18 | memotest.Sequential(t, m) 19 | } 20 | 21 | func TestConcurrent(t *testing.T) { 22 | m := memo.New(httpGetBody) 23 | defer m.Close() 24 | memotest.Concurrent(t, m) 25 | } 26 | -------------------------------------------------------------------------------- /go/z-gopl/go.mod: -------------------------------------------------------------------------------- 1 | module gopl.io 2 | 3 | go 1.16 4 | 5 | require golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6 6 | -------------------------------------------------------------------------------- /interview-list/230311-meituan-美团/meituan.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 2 1 5 3 | 6 3 7 4 | # 2 4 5 | 6 | 1 7 | 1 8 | 2 9 | 10 | -------------------------------------------------------------------------------- /interview-list/230311-meituan-美团/meituan3.sh: -------------------------------------------------------------------------------- 1 | 1 7 2 2 | BBRBRBR 3 | 0 3 2 4 1 1 1 4 | # 5 5 | 6 | 3 3 3 7 | BBR 8 | BRB 9 | RBB 10 | 0 1 10 11 | 2 10 100 12 | 10 100 100 13 | # 2 -------------------------------------------------------------------------------- /interview-list/230312-duoduo-拼多多/2303-duoduo.md: -------------------------------------------------------------------------------- 1 | 2 | - 对于压缩表示的字母字符串进行decode; 需要处理数量>9的情况, 例如 `10a1b` #easy 3 | - 飞机大战: 一种子弹对两个敌人各造成1点伤害, 另一种秒杀一个人; 问最少需要按几次按键 #easy 4 | - 团建: 有三个活动ABC, 分别有人数限制和每个人的费用; 给定每个人的意向 (可以是多个), 问是否可以安排, 最小费用 5 | - 好复杂的样子... 暴力写了个复杂的模拟 6 | - 给定一个序列的长度n,接下来n个数,表示一个序列,要求输出这个序列的中位数和平均数,中位数和平均数都要四舍五入到整数. 模版题 7 | -------------------------------------------------------------------------------- /interview-list/230312-duoduo-拼多多/duoduo3.sh: -------------------------------------------------------------------------------- 1 | 5 2 | A 3 | B 4 | C 5 | AB 6 | ABC 7 | 2 1 8 | 2 2 9 | 2 3 10 | # YES 11 | # 9 12 | 13 | 14 | 5 15 | A 16 | B 17 | C 18 | AB 19 | AB 20 | 1 1 21 | 2 2 22 | 3 3 23 | # NO 24 | # 4 25 | -------------------------------------------------------------------------------- /interview-list/230312-duoduo-拼多多/duoduo4.sh: -------------------------------------------------------------------------------- 1 | 5 2 | 1 2 3 4 10 3 | -------------------------------------------------------------------------------- /interview-list/230313-baidu-百度/01.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 1 2 3 3 | 4 | 5 5 | 1 2 3 2 2 -------------------------------------------------------------------------------- /interview-list/230315-hackerrate/4-3.sh: -------------------------------------------------------------------------------- 1 | 2 2 | 5 3 | 2 1 5 3 4 4 | 5 5 | 2 5 1 3 4 6 | # 3 7 | # Too chaotic 8 | 9 | -------------------------------------------------------------------------------- /interview-list/230315-hackerrate/5-2.sh: -------------------------------------------------------------------------------- 1 | 10 2 | 1 42 3 | 2 4 | 1 14 5 | 3 6 | 1 28 7 | 3 8 | 1 60 9 | 1 78 10 | 2 11 | 2 12 | # 14 13 | # 14 -------------------------------------------------------------------------------- /interview-list/230315-hackerrate/6-2.sh: -------------------------------------------------------------------------------- 1 | 4 2 | 2 2 3 | 3 2 4 | 2 3 5 | 4 4 6 | # 3 7 | # 7 8 | # 9 9 | # 3375 -------------------------------------------------------------------------------- /interview-list/230315-hackerrate/7-1.sh: -------------------------------------------------------------------------------- 1 | 6 2 | 1 2 5 3 6 4 3 | # 1 2 5 3 4 6 -------------------------------------------------------------------------------- /interview-list/230315-hackerrate/7-2.sh: -------------------------------------------------------------------------------- 1 | Rumpelstiltskin 2 | # Output同 -------------------------------------------------------------------------------- /interview-list/230315-optiver/1.sh: -------------------------------------------------------------------------------- 1 | 6 2 | PRICE Facebook 80 3 | PRICE Apple 120 4 | TRADE 100 Apple SELL 90 2 5 | TRADE 10 Facebook BUY 100 4 6 | WORST_TRADE Facebook 7 | WORST_TRADE Apple 8 | # 10 9 | # 100 10 | 11 | 10 12 | PRICE Google 100 13 | TRADE 1 Google BUY 100 10 14 | WORST_TRADE Google 15 | TRADE 2 Google SELL 102 5 16 | TRADE 3 Google SELL 103 5 17 | PRICE Google 98 18 | WORST_TRADE Google 19 | TRADE 4 Google BUY 101 10 20 | TRADE 5 Google BUY 100 10 21 | WORST_TRADE Google 22 | # NO BAD TRADES 23 | # 1 24 | # 4 25 | -------------------------------------------------------------------------------- /interview-list/230315-optiver/2.sh: -------------------------------------------------------------------------------- 1 | LIMIT ABC 100.0 1000 100.0 2 | ORDER ABC 10000000 10 8.0 3 | ORDER ABC 10000300 10 8.0 4 | # MAX_VAL_1S_LIMIT ABC 5 | 6 | LIMIT ABC 100.0 1000 100.0 7 | ORDER ABC 10000000 10 8.0 8 | # 空 -------------------------------------------------------------------------------- /interview-list/230315-optiver/README.txt: -------------------------------------------------------------------------------- 1 | Optiver 笔试, 平台可以选择Python但居然没有template, 手动将cpp转为Python实现了一下 2 | 最后是 T1 AC, T2 到最后发现了问题, 但没有来得及测试是否是这个问题 orz 3 | 4 | 5 | 处理Python读取的时候遇到 EOF 的问题(最后一行没有换行) 6 | g++ 编译还需要熟悉一下 7 | -------------------------------------------------------------------------------- /interview-list/230316-ant-蚂蚁/1.py: -------------------------------------------------------------------------------- 1 | """ 一个01序列, 进行k个反转操作, 求可以得到的最大数字 2 | 思路1: 尽可能将前面的数字都变成1, 如果有多余的操作就吧末尾变成0 3 | """ 4 | 5 | s = list(map(int, input().strip())) 6 | k = int(input()) 7 | 8 | for i,x in enumerate(s): 9 | if x==0 and k>0: 10 | s[i] = 1; k-=1 11 | if k%2==1: 12 | s[-1] = 0 13 | print("".join(map(str, s))) 14 | 15 | -------------------------------------------------------------------------------- /interview-list/230316-ant-蚂蚁/1.sh: -------------------------------------------------------------------------------- 1 | 1000 2 | 2 3 | # 1110 4 | 5 | 111 6 | 1 7 | # 110 -------------------------------------------------------------------------------- /interview-list/230316-ant-蚂蚁/2.sh: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 3 | # 4 4 | 5 | -------------------------------------------------------------------------------- /interview-list/230316-ant-蚂蚁/3.sh: -------------------------------------------------------------------------------- 1 | 2 3 1 2 | 2 1 3 | 1 2 3 4 | 2 5 | 6 7 6 | # 1 7 | 8 | 2 2 2 9 | 1 1 10 | 2 3 11 | 3 2 12 | 6 7 13 | # 4 -------------------------------------------------------------------------------- /interview-list/230319-miHoYo-米哈游/1.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | s = sys.stdin.readline().strip() 4 | n = len(s) 5 | def f(s): 6 | for i in range(n-2): 7 | if s[i]i: 14 | if arr[x]==i: ans += 1 15 | anss.append(ans) 16 | print(sum(anss)/len(anss)) 17 | -------------------------------------------------------------------------------- /interview-list/230319-miHoYo-米哈游/b.py: -------------------------------------------------------------------------------- 1 | 2 | #%% 3 | class List: 4 | def __init__(self) -> None: 5 | self.list = [1,2] 6 | def __getitem__(self, index): 7 | return self.list[index] 8 | 9 | 10 | # %% 11 | myL = List() 12 | 13 | #%% 14 | 2 in myL 15 | 16 | # %% 17 | for i in myL: 18 | print(i) 19 | 20 | # %% 21 | bool(myL) 22 | 23 | # %% 24 | myL[0] 25 | 26 | # %% 27 | -------------------------------------------------------------------------------- /interview-list/230321-ant-deer/1.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | """ 反转字符串中的大写序列 4 | 思路1: #栈 5 | """ 6 | 7 | s = input().strip() 8 | import string 9 | 10 | st = [] 11 | ans = [] 12 | for i in s: 13 | if i in string.ascii_uppercase: 14 | st.append(i) 15 | else: 16 | while st: 17 | ans.append(st.pop()) 18 | ans.append(i) 19 | # 加两行 20 | while st: 21 | ans.append(st.pop()) 22 | ans = "".join(ans) 23 | print(ans) 24 | 25 | 26 | -------------------------------------------------------------------------------- /interview-list/230321-ant-deer/1.sh: -------------------------------------------------------------------------------- 1 | ABCajfjalfjDFajfaf 2 | # CBAajfjalfjFDajfaf 3 | 4 | -------------------------------------------------------------------------------- /interview-list/230321-ant-deer/2.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | 对于一个序列, 计算 (i,j,k) 组, 满足 2j = i+k 4 | 限制: n 2e3 5 | 思路1: 两两匹配枚举 6 | """ 7 | 8 | from collections import Counter 9 | n = int(input()) 10 | arr = list(map(int, input().split())) 11 | cnt = Counter(arr) 12 | ans = 0 13 | # 枚举中间的那个均值 14 | for i,c1 in cnt.items(): 15 | # 枚举剩余的两个数字, 计数 16 | # i = j=k 17 | if c1>=3: ans += c1*(c1-1)*(c1-2) 18 | # 不相等的情况 19 | for j,c2 in cnt.items(): 20 | if i==j: continue 21 | ans += c1*c2*cnt[2*j-i] 22 | print(ans) 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /interview-list/230321-ant-deer/2.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 1 1 1 3 | # 6 4 | 5 | 3 6 | 1 2 3 7 | # 2 8 | -------------------------------------------------------------------------------- /interview-list/230321-ant-deer/3.sh: -------------------------------------------------------------------------------- 1 | 2 | 4 3 3 | 1 2 4 | 1 3 5 | 1 4 6 | 2 R 7 | 3 G 8 | 4 B 9 | # 0 10 | 11 | 4 1 12 | 1 2 13 | 1 3 14 | 1 4 15 | 1 R 16 | # 8 17 | 18 | -------------------------------------------------------------------------------- /interview-list/230321-ant-deer/a.py: -------------------------------------------------------------------------------- 1 | #%% 2 | import heapq 3 | 4 | q = [7,11,23,32,16,9,12,45,27] 5 | q = [-i for i in q] 6 | heapq.heapify(q) 7 | q = [-i for i in q] 8 | print(q) 9 | 10 | # %% 11 | -------------------------------------------------------------------------------- /interview-list/230326-tecent/1.py: -------------------------------------------------------------------------------- 1 | """ 选择题 2 | 思路1; #模拟 3 | 4 | """ 5 | n = int(input()) 6 | pre = input().split() 7 | ans = input().split() 8 | 9 | acc = 0 10 | for p,a in zip(pre, ans): 11 | if p==a: acc += 3 12 | elif all(i in a for i in p): acc += 1 13 | print(acc) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /interview-list/230326-tecent/1.sh: -------------------------------------------------------------------------------- 1 | 3 2 | AB ACD B 3 | AB ACD B 4 | # 9 5 | 3 6 | ABC AB CD 7 | ABC ABD BC 8 | # 4 -------------------------------------------------------------------------------- /interview-list/230326-tecent/2.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 1 3 3 | 5 8 4 | 1 6 5 | # 0 6 | # 0 7 | # 1 -------------------------------------------------------------------------------- /interview-list/230326-tecent/3.sh: -------------------------------------------------------------------------------- 1 | 2 2 | 3 10.5 3 | 4.5 3.4 6.5 4 | 3 2.2 5 | 4.5 3.4 6.5 6 | # 0 7 | # 1 8 | -------------------------------------------------------------------------------- /interview-list/230326-tecent/4.sh: -------------------------------------------------------------------------------- 1 | 4 2 2 | 2 3 3 2 3 | # 2 4 | 3 1 5 | 2 3 3 6 | # 3 7 | 8 | -------------------------------------------------------------------------------- /interview-list/230326-tecent/5.sh: -------------------------------------------------------------------------------- 1 | 1 1 2 | 1 3 | 0 0 1 1 4 | # 2 5 | 1 2 6 | 2 7 | 0 0 1 1 8 | 1 1 2 0 9 | # 3 10 | 2 2 11 | 2 12 | 0 0 1 1 13 | 0 1 1 0 14 | # 4 -------------------------------------------------------------------------------- /interview-list/230329-携程-deer/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 统计数字中「圆圈」的数量 3 | """ 4 | 5 | ones = '069' 6 | twos = '8' 7 | 8 | s = input().strip() 9 | ans = 0 10 | for c in s: 11 | if c in ones: 12 | ans += 1 13 | elif c in twos: ans += 2 14 | print(ans) 15 | -------------------------------------------------------------------------------- /interview-list/230329-携程-deer/1.sh: -------------------------------------------------------------------------------- 1 | 0123456789 2 | # 5 3 | -------------------------------------------------------------------------------- /interview-list/230329-携程-deer/2.py: -------------------------------------------------------------------------------- 1 | """ 构造一个排列 2 | 对于位置i的元素x, 若其为左侧的最大值; 不相邻 3 | 贪心构造: 就是取最后的k个元素放在最前面! 为了避免相邻, 交替放置这些vals即可~ 4 | """ 5 | n, k = map(int, input().split()) 6 | arr = list(range(1,n+1)) 7 | vals, other = arr[-k:], arr[:-k] 8 | ans = [] 9 | for i in range(k): 10 | ans += [vals[i], other[i]] 11 | ans += other[k:] 12 | ans = list(map(str, ans)) 13 | print(" ".join(ans)) -------------------------------------------------------------------------------- /interview-list/230329-携程-deer/2.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230329-携程-deer/2.sh -------------------------------------------------------------------------------- /interview-list/230329-携程-deer/3.sh: -------------------------------------------------------------------------------- 1 | 2 2 | # 1 1 3 | 25 4 | # 3 5 -------------------------------------------------------------------------------- /interview-list/230329-携程-deer/4.sh: -------------------------------------------------------------------------------- 1 | 5 2 | 1 2 2 3 | 2 3 5 4 | 3 4 4 5 | 3 5 3 6 | # 6 7 | 3 8 | 1 2 2 9 | 2 3 2 10 | 11 | 5 12 | 1 2 6 13 | 2 3 2 14 | 2 4 3 15 | 2 5 3 16 | -------------------------------------------------------------------------------- /interview-list/230329-携程-deer/xiecheng.md: -------------------------------------------------------------------------------- 1 | 1] 计算MLP网络的参数数量 2 | 2] 求一个简单的概率积分 3 | 3] 一趟聚类(One-pass Cluster)和kmeans 4 | 4] 求置信区间 n=9, a=0.05 5 | TODO 6 | 5] 给定support=0.6, 求最大频繁项集. 需要清楚「支持度」的定义是 cnt/cnt_all 7 | 6] 考察聚类函数. 一张图上包括了: 轮廓系数 SSE 两条折线, 求最佳的k值 8 | 7] 一道简单的概率题 9 | 8] 考察dropout在测试的时候没有影响. 10 | 11 | 12 | -------------------------------------------------------------------------------- /interview-list/230330-pdd-拼多多/1.sh: -------------------------------------------------------------------------------- 1 | 5 2 2 | b 1 3 | b 2 4 | m 1 10 5 | m 2 20 6 | m 2 30 7 | # 30 8 | 6 2 9 | b 1 10 | b 2 11 | m 2 20 12 | b 2 13 | m 2 20 14 | m 1 30 15 | # 40 -------------------------------------------------------------------------------- /interview-list/230330-pdd-拼多多/2.sh: -------------------------------------------------------------------------------- 1 | 4 2 | 1 2 0 3 | 2 3 1 4 | 2 4 1 5 | # 2 6 | 4 7 | 1 2 1 8 | 2 3 0 9 | 3 4 1 10 | # 1 11 | 4 12 | 1 2 1 13 | 2 3 0 14 | 2 4 1 15 | # 1 16 | 2 17 | 1 2 1 -------------------------------------------------------------------------------- /interview-list/230330-pdd-拼多多/3.sh: -------------------------------------------------------------------------------- 1 | 4 2 | 1 4 -1 4 3 | # 0 1 4 | 5 5 | 2 0 -2 8 -1 6 | # 2 4 7 | 1 8 | 0 9 | # -1 10 | 2 11 | 0 0 12 | # -1 13 | 14 | # 注意相等的时候取后面的! 这个卡了好久... 15 | 5 16 | -8 -1 0 -1 -8 17 | # 3 4 -------------------------------------------------------------------------------- /interview-list/230330-pdd-拼多多/4.sh: -------------------------------------------------------------------------------- 1 | 5 2 | 3 3 | 3 3 2 4 | 4 5 | 1 3 1 3 6 | 5 7 | 4 1 5 3 2 8 | 4 9 | 2 4 1 2 10 | 1 11 | 1 12 | # 1 13 | # 2 14 | # 4 15 | # 3 16 | # 0 -------------------------------------------------------------------------------- /interview-list/230406-Morgan-Stanley/0.py: -------------------------------------------------------------------------------- 1 | #%% 2 | 2**24 3 | # %% 4 | from queue import PriorityQueue -------------------------------------------------------------------------------- /interview-list/230406-Morgan-Stanley/3.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | """ 4 | 对于一个字符串, 计算将其排序之后成为回文串, 需要修改的的最小操作次数 5 | 对于字符串的所有子串, 求操作次数之和. 限制: n 2e5 6 | 思路1: 7 | 起作用的只有奇数个字符的数量, 例如 1,2,3,4,5... 分别对应了 0,1,1,2,2,... 8 | 如何记录? 字符范围 a-z, #状压 表示奇偶性即可 9 | 10 | """ 11 | -------------------------------------------------------------------------------- /interview-list/230408-Meituan/1.py: -------------------------------------------------------------------------------- 1 | """ 换座位 2 | n行, m大列, a小列. 每次换到下一行, 下一大列的相同小列上. 对于0/1高度, 判断多少需要调整的. 3 | 限制: n,m 200; a 5 4 | 5 | """ 6 | n,m,a = map(int, input().split()) 7 | seats = [] 8 | for _ in range(n): 9 | seats.append(list(input().strip().replace(" ", ""))) 10 | ans = 0 11 | for i in range(n): 12 | for j in range(m*a): 13 | ni = (i+1)%n 14 | nj = (j+a)%(m*a) 15 | if seats[i][j] != seats[ni][nj]: 16 | ans += 1 17 | print(ans) 18 | 19 | -------------------------------------------------------------------------------- /interview-list/230408-Meituan/1.sh: -------------------------------------------------------------------------------- 1 | 3 3 2 2 | 01 10 00 3 | 10 00 11 4 | 01 00 00 5 | # 8 -------------------------------------------------------------------------------- /interview-list/230408-Meituan/2.sh: -------------------------------------------------------------------------------- 1 | 7 2 | 1 2 3 4 5 3 3 | 3 7 4 | # 4 5 | 6 | 2 7 | 1 8 | 1 2 9 | # 1 10 | 11 | 4 12 | 1 2 3 13 | 1 2 14 | # 3 15 | 8 16 | 1 2 3 2 2 3 3 17 | 1 2 18 | 19 | 5 20 | 1 1 1 1 21 | 1 2 22 | -------------------------------------------------------------------------------- /interview-list/230408-Meituan/230408-Meituan.md: -------------------------------------------------------------------------------- 1 | T2 因为递归栈的问题排查了好久... T3做不出来TLE了 2 | 3 | 1] 哪些网络层是非线性的 4 | ReLU; Softmax 5 | CNN, BatchNorm 6 | 2] K-means 7 | 是分类模型 8 | 无监督 9 | 训练数据有标签 10 | K值需要手动设置 11 | 3] RL的基本要素 12 | Environment 13 | Reward Function 14 | Value Function 15 | Policy 16 | -------------------------------------------------------------------------------- /interview-list/230408-Meituan/3.sh: -------------------------------------------------------------------------------- 1 | 6 4 3 2 | 1 4 5 1 4 1 3 | # 21 4 | # 打包前3个/后3个 -------------------------------------------------------------------------------- /interview-list/230408-Meituan/4.sh: -------------------------------------------------------------------------------- 1 | 5 6 2 2 | 2 1 3 | 2 3 4 | 1 1 5 1 5 | # 1 -------------------------------------------------------------------------------- /interview-list/230412-alibaba/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 要求构造一个01序列, 长n, 包括k个长为3的回文串 3 | 边界: n<3! 4 | 1 0 5 | """ 6 | 7 | n,k = map(int, input().split()) 8 | if n<3: 9 | print(-1 if k>0 else '0'*n) 10 | elif k>n-2: 11 | # 注意不可能的情况! 12 | print(-1) 13 | else: 14 | ans = '1' * (k+2) 15 | r = n-k-2 16 | ans += ('0011' * (r//4+1))[:r] 17 | print(ans) -------------------------------------------------------------------------------- /interview-list/230412-alibaba/1.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230412-alibaba/1.sh -------------------------------------------------------------------------------- /interview-list/230412-alibaba/2.py: -------------------------------------------------------------------------------- 1 | """ 2 | 对于两个字符串, 将其中的字符看成节点, 对于相同字符之间连边. 问有多少可能的二分图. 对结果取模 3 | 4 | 不知道哪里错了? 只过了5% 5 | """ 6 | from collections import Counter 7 | from math import perm 8 | mod = 10**9 + 7 9 | n = int(input()) 10 | s1 = input().strip() 11 | s2 = input().strip() 12 | c1,c2 = Counter(s1), Counter(s2) 13 | ans = 1 14 | for v,cc1 in c1.items(): 15 | cc2 = c2[v] 16 | a,b = sorted([cc1,cc2]) 17 | # 下面人循环 % 会快一些 18 | ans = (ans*perm(b,a))%mod 19 | print(ans) 20 | -------------------------------------------------------------------------------- /interview-list/230412-alibaba/2.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230412-alibaba/2.sh -------------------------------------------------------------------------------- /interview-list/230412-alibaba/230412-ali.md: -------------------------------------------------------------------------------- 1 | 2 | 条件概率计算 3 | 4 | 问一个森林, 中序遍历 cbdafegh, 后序 cdbfhgea, 问有几棵树 5 | 6 | 低位优先的基数排序 7 | 8 | 对于两个矩阵A,B, 秩都为5; 合起来 (A,B) 的秩也为5. 问性质 9 | 10 | 多选 11 | 矩阵A有 $A^2=I$, 问性质 12 | $A^A, A$ 相似矩阵? 13 | $|A|^2 = 1$ 14 | A 必然为 I 15 | A可逆 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /interview-list/230412-alibaba/3.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 2 1 4 3 | 4 4 | 1 2 5 | 2 3 6 | 3 4 7 | # 6 -------------------------------------------------------------------------------- /interview-list/230415-携程/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 在 (n,m) 的grid中, 统计 (2,2) 的包含了you三个字母的矩形的个数. 3 | """ 4 | n,m = map(int, input().split()) 5 | grid = [] 6 | for _ in range(n): 7 | grid.append(list(input().strip())) 8 | ans = 0 9 | for i in range(n-1): 10 | for j in range(m-1): 11 | chs = [grid[i][j], grid[i+1][j], grid[i][j+1], grid[i+1][j+1]] 12 | if all(ch in chs for ch in "you"): 13 | ans += 1 14 | print(ans) 15 | 16 | -------------------------------------------------------------------------------- /interview-list/230415-携程/1.sh: -------------------------------------------------------------------------------- 1 | 3 3 2 | yuo 3 | uiy 4 | our 5 | # 1 -------------------------------------------------------------------------------- /interview-list/230415-携程/2.sh: -------------------------------------------------------------------------------- 1 | 5 2 | 2 3 | 5 4 | 4 5 | 10 6 | # 2 3 7 | # 1 3 8 | -------------------------------------------------------------------------------- /interview-list/230415-携程/230415-xiecheng.md: -------------------------------------------------------------------------------- 1 | 2 | 1] 考察SNN相似度? 看题目挺简单的 3 | 2] (0,1), (1,2), (2,2) 三个点, LR的均方误差? 4 | 盲猜1/4 5 | 5] $X \sim N(\mu, \sigma^2), Y \sim N(2\mu, 2\sigma^2)$, 两个数字 $p_1 = P(|X-\mu| > 2\sigma^2), p_2 = P(X-Y>0)$, 求两个数字的大小关系? 已知 $\phi(1) = 0.84$ 6 | 无法确定? 7 | -------------------------------------------------------------------------------- /interview-list/230415-携程/3.sh: -------------------------------------------------------------------------------- 1 | 4 4 5 2 | 1010 3 | 1 2 4 | 2 3 5 | 3 4 6 | # 3 7 | 8 | 3 1 2 9 | 100 10 | 1 2 11 | 1 3 12 | # 6 13 | 14 | 4 0 20 15 | 1010 16 | 1 2 17 | 1 3 18 | 1 4 19 | 20 | 5 7 13 21 | 10110 22 | 1 2 23 | 2 3 24 | 1 4 25 | 4 5 26 | # 10 27 | -------------------------------------------------------------------------------- /interview-list/230415-携程/4.sh: -------------------------------------------------------------------------------- 1 | 1 2 | 3 3 | # 6 4 | 3 5 | 1 1 1 6 | # 4 -------------------------------------------------------------------------------- /interview-list/230419-jgc-Ali/2.sh: -------------------------------------------------------------------------------- 1 | 5 2 | rbbrr 3 | 1 2 4 | 2 3 5 | 3 4 6 | 5 2 7 | # 2 -------------------------------------------------------------------------------- /interview-list/230419-jgc-Ali/3.sh: -------------------------------------------------------------------------------- 1 | 2 2 | # 325 -------------------------------------------------------------------------------- /interview-list/230419-pinduoduo/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 统计棱形的数量, 满足所有点的横坐标满足 0<=x<=X, 0<=y<=Y, 并且对称轴平行于坐标轴 3 | 思路1: 数学 4 | 横坐标之差显然需要是偶数, 枚举长度为 2,4,...X 的棱形 5 | 计数平行X的对称轴可能的数量: X-1 + X-3 + ... 6 | 对于横轴高度为y的棱形, 它能够匹配的棱形数量为 min( y, Y-y ) 7 | """ 8 | x,y = map(int, input().split()) 9 | factor = 0 10 | x -= 1 11 | while x > 0: 12 | factor += x 13 | x -= 2 14 | ans = 0 15 | for i in range(y): 16 | ans += min(i, y-i) * factor 17 | print(ans) -------------------------------------------------------------------------------- /interview-list/230419-pinduoduo/1.sh: -------------------------------------------------------------------------------- 1 | 2 2 2 | # 1 -------------------------------------------------------------------------------- /interview-list/230419-pinduoduo/2.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 1 2 3 | 4 1 4 | 2 5 5 | # 1 4 6 | 7 | 3 8 | 1 2 9 | 3 2 10 | 2 4 11 | # -1 -------------------------------------------------------------------------------- /interview-list/230419-pinduoduo/3.py: -------------------------------------------------------------------------------- 1 | """ 压缩表示 2 | 有M个维度, 每个维度的取值有Mi种可能; 对于T个配置情况进行压缩表示, 每个配置情况有一个值Ti. 问这些配置行可以被压缩成最少多少行 3 | 限制: M 5; Mi 5; T 20; Ti 100. 4 | """ 5 | M = int(input()) 6 | filed2keys = {} 7 | for i in range(M): 8 | line = input().split() 9 | filed2keys[i] = line[1:] 10 | T = int(input()) 11 | items = {} 12 | for _ in range(T): 13 | line = input().split() 14 | items[tuple(line[:-1])] = int(line[-1]) 15 | 16 | -------------------------------------------------------------------------------- /interview-list/230419-pinduoduo/3.sh: -------------------------------------------------------------------------------- 1 | 2 2 | 2 A B 3 | 2 T F 4 | 3 5 | A T 1 6 | A F 1 7 | B T 1 8 | # 2 9 | # A ALL 1 10 | # B T 1 11 | # or 12 | # ALL T 1 13 | # A F 1 14 | # or 15 | # ALL T 1 16 | # A ALL 1 17 | 18 | 2 19 | 2 A B 20 | 2 T F 21 | 4 22 | A T 1 23 | A F 1 24 | B T 1 25 | B F 1 26 | # 1 27 | # ALL ALL 1 28 | 29 | 2 30 | 2 A B 31 | 1 T 32 | 2 33 | A T 1 34 | B T 2 35 | # 2 36 | # 无法进行简化 -------------------------------------------------------------------------------- /interview-list/230419-pinduoduo/4.sh: -------------------------------------------------------------------------------- 1 | 4 2 | 1 3 | 2 4 | 5 5 | 6 6 | # 1 0 7 | # 1 1 8 | # 2 3 9 | # 4 2 10 | -------------------------------------------------------------------------------- /interview-list/230422-deer-Meituan/1.py: -------------------------------------------------------------------------------- 1 | """ 检查是否可以拿到奖学金. 1] 所有成绩不低于60; 2 | T 10; n 1e3; 3 | 4 | """ 5 | T = int(input()) 6 | def f(): 7 | n,X = map(int, input().strip().split()) 8 | A = list(map(int, input().strip().split())) 9 | B = list(map(int, input().strip().split())) 10 | if min(B) < 60: return False 11 | avg = sum(a*b for a,b in zip(A,B)) / sum(A) 12 | return avg>=X 13 | for _ in range(T): 14 | ret = f() 15 | print('Yes' if ret else 'No') -------------------------------------------------------------------------------- /interview-list/230422-deer-Meituan/1.sh: -------------------------------------------------------------------------------- 1 | 2 2 | 4 97 3 | 2 2 2 2 4 | 94 97 100 100 5 | 4 93 6 | 10 6 7 9 7 | 59 93 100 95 8 | # Yes 9 | # No -------------------------------------------------------------------------------- /interview-list/230422-deer-Meituan/2.py: -------------------------------------------------------------------------------- 1 | """ 检查骰子是否合法. 要求相对面之和相同, 面数为n 2 | T 100; n 1e5; 数字 1e5 3 | 4 | 思路1: #贪心 5 | 排序之后检查是否和相同 6 | """ 7 | T = int(input()) 8 | def f(): 9 | n = int(input()) 10 | if n%2: return False 11 | arr = list(map(int, input().strip().split())) 12 | arr.sort() 13 | tgt = arr[0] + arr[-1] 14 | for i in range(n//2): 15 | if arr[i] + arr[-i-1] != tgt: return False 16 | return True 17 | 18 | for _ in range(T): 19 | ret = f() 20 | print("YES" if ret else "NO") 21 | -------------------------------------------------------------------------------- /interview-list/230422-deer-Meituan/2.sh: -------------------------------------------------------------------------------- 1 | 2 2 | 6 3 | 1 2 3 4 2 3 4 | 6 5 | 1 2 4 5 6 7 6 | # YES 7 | # NO -------------------------------------------------------------------------------- /interview-list/230422-deer-Meituan/3.sh: -------------------------------------------------------------------------------- 1 | 3 12 2 | 3 4 7 3 | 9 3 2 4 | 11 6 11 5 | # 12 6 | 7 | -------------------------------------------------------------------------------- /interview-list/230422-deer-Meituan/4.sh: -------------------------------------------------------------------------------- 1 | 101110110 2 | # 2 3 | 4 | 拓展性, 类型自动转换, 不支持批量导入数据, 只能对表进行查询 -------------------------------------------------------------------------------- /interview-list/230426-Amazon/1.py: -------------------------------------------------------------------------------- 1 | """ 简单 """ 2 | from collections import Counter 3 | def getUniqueCharacter(s): 4 | cnt = Counter(s) 5 | for i,x in enumerate(s): 6 | if cnt[x]==1: return i+1 7 | return -1 8 | 9 | for s in ["hackthegame", "falafal"]: 10 | print(getUniqueCharacter(s)) 11 | -------------------------------------------------------------------------------- /interview-list/230426-Amazon/2.py: -------------------------------------------------------------------------------- 1 | """ 2 | 合并区间 3 | """ 4 | 5 | def getMergedIntervals(intervals): 6 | intervals.sort() 7 | ans = [] 8 | ll,rr = intervals[0] 9 | for l,r in intervals[1:]: 10 | if l<=rr: 11 | rr = max(rr,r) 12 | else: 13 | ans.append([ll,rr]) 14 | ll,rr = l,r 15 | ans.append([ll,rr]) 16 | return ans 17 | 18 | print( 19 | getMergedIntervals([[4,8],[2,6],[5,7]]), 20 | ) 21 | -------------------------------------------------------------------------------- /interview-list/230428-Merchants-招商银行/1.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230428-Merchants-招商银行/1.sh -------------------------------------------------------------------------------- /interview-list/230428-Merchants-招商银行/2.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230428-Merchants-招商银行/2.sh -------------------------------------------------------------------------------- /interview-list/230428-Merchants-招商银行/3.py: -------------------------------------------------------------------------------- 1 | """ 2 | 对于一个数字, 统计满足条件的数组: h!=t, 同时 (h..t) 之间的元素都不等于h/t 3 | 限制: N 2e5; 数组的元素范围 N 4 | 5 | 7 6 | 1 2 3 4 3 2 5 7 | # 13 8 | # 注意区间 (1,7) 也满足! 9 | 4 10 | 1 2 1 2 11 | # 3 12 | 13 | 思路0: 不会做, 下面写了个 O(n^2) 的实现. 14 | 15 | """ 16 | n = int(input()) 17 | arr = list(map(int, input().split())) 18 | ans = 0 19 | for i,x in enumerate(arr): 20 | s = set() 21 | for j in range(i+1,n): 22 | y = arr[j] 23 | if y==x: break 24 | if y in s: continue 25 | s.add(y) 26 | ans += 1 27 | print(ans) 28 | 29 | -------------------------------------------------------------------------------- /interview-list/230428-Merchants-招商银行/3.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230428-Merchants-招商银行/3.sh -------------------------------------------------------------------------------- /interview-list/230428-Merchants-招商银行/t.py: -------------------------------------------------------------------------------- 1 | def quick_sort(arr): 2 | if len(arr) <= 1: 3 | return arr 4 | else: 5 | pivot = arr[0] 6 | left = [] 7 | right = [] 8 | for i in range(1, len(arr)): 9 | if arr[i] < pivot: 10 | left.append(arr[i]) 11 | else: 12 | right.append(arr[i]) 13 | return quick_sort(left) + [pivot] + quick_sort(right) 14 | 15 | quick_sort([14,8,20,21,1,7,4,11,6]) -------------------------------------------------------------------------------- /interview-list/230502-Merchants-招商银行/1.sh: -------------------------------------------------------------------------------- 1 | 6 5 2 | 1 4 2 5 3 4 3 | 10100 4 | 00010 5 | 01100 6 | 01000 7 | 11111 8 | # 9 -------------------------------------------------------------------------------- /interview-list/230502-Merchants-招商银行/2.sh: -------------------------------------------------------------------------------- 1 | 10 2 | 7 3 | 1 2 3 4 5 6 7 4 | 4 5 | 4 5 7 8 6 | 4 7 | 4 5 7 9 8 | 4 9 | 4 5 7 10 10 | 4 11 | 4 5 7 11 12 | 4 13 | 4 5 7 12 14 | 4 15 | 4 5 7 13 16 | 4 17 | 4 5 7 14 18 | 4 19 | 4 5 7 15 20 | 4 21 | 4 5 7 16 22 | # 1 23 | # 3 24 | # 5 25 | # 1 26 | # 4 27 | # 3 28 | # 0 29 | # 0 30 | # 0 31 | # 1 32 | -------------------------------------------------------------------------------- /interview-list/230502-Merchants-招商银行/230502.md: -------------------------------------------------------------------------------- 1 | 在TCP协议中, 2 | 3 | -------------------------------------------------------------------------------- /interview-list/230502-Merchants-招商银行/3.py: -------------------------------------------------------------------------------- 1 | """ 产品转换 2 | 有N种产品, 可以有K种产品转换方案, 将若干产品转化为某一个新的产品; 对于某一用户持有的产品分布, 问可能得到的最多的最新产品(序号N)的的数量 3 | 限制: K,N 1e2; 用户持有的数量 1e4 4 | """ 5 | 6 | -------------------------------------------------------------------------------- /interview-list/230502-Merchants-招商银行/3.sh: -------------------------------------------------------------------------------- 1 | 5 2 | 2 0 0 1 0 3 | 3 4 | 5 2 3 4 5 | 2 1 1 6 | 3 1 2 7 | # 1 -------------------------------------------------------------------------------- /interview-list/230722-oppo/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 给定 x,y, 从数组A中选择一定的数字, 使得乘以x得到的数字大于y 3 | """ 4 | x,y = map(int, input().split()) 5 | n = int(input()) 6 | a = list(map(int, input().split())) 7 | a = sorted(set(a), reverse=True) 8 | ans = 0 9 | idx = 0 10 | while idx<(len(a)) and x 0: 18 | heapq.heappush(h, (-aa-b[i-1], aa, i-1)) 19 | print(" ".join(map(str, ans))) -------------------------------------------------------------------------------- /interview-list/230729-Shein-NLP/2.py: -------------------------------------------------------------------------------- 1 | """ 给定一组数字, 问和构成60的方案数量 2 | """ 3 | from collections import Counter 4 | n = int(input()) 5 | arr = list(map(int, input().split())) 6 | cnt = Counter() 7 | ans = 0 8 | for x in arr: 9 | ans += int(x==60) 10 | ans += cnt[60-x] 11 | for k,v in cnt.copy().items(): 12 | cnt[k+x] += v 13 | cnt[x] += 1 14 | print(ans) 15 | -------------------------------------------------------------------------------- /interview-list/230729-Shein-NLP/2.sh: -------------------------------------------------------------------------------- 1 | 4 2 | 30 30 60 60 3 | # 3 -------------------------------------------------------------------------------- /interview-list/230729-Shein-NLP/3.sh: -------------------------------------------------------------------------------- 1 | 3*(6 - 1)/5 2 | # 3 3 | 3*(6 - 1)/7 4 | # 3 5 | -------------------------------------------------------------------------------- /interview-list/230729-Shein/1.sh: -------------------------------------------------------------------------------- 1 | 3 20 2 | 5 2 3 3 | # 4 4 | 3 0 5 | 5 2 3 6 | # 0 7 | 2 2 8 | 3 5 9 | # -1 10 | -------------------------------------------------------------------------------- /interview-list/230729-Shein/2.py: -------------------------------------------------------------------------------- 1 | """ 最长的没有重复元素的子串长度 返回字符串中, 最长的没有重复元素的子串长度 2 | 限制: n 1e5 3 | """ 4 | 5 | def lengthOfLongestSubstring(arr) -> int: 6 | s = set() 7 | l = 0 8 | ans = 0 9 | for r,x in enumerate(arr): 10 | if x in s: 11 | while arr[l] != x: 12 | s.remove(arr[l]) 13 | l += 1 14 | l += 1 15 | s.add(x) 16 | ans = max(ans, r-l+1) 17 | return ans 18 | 19 | for a in [ 20 | "abcabcbb", 21 | "bbbbb", 22 | "pwwkew", 23 | "", 24 | ]: 25 | print(lengthOfLongestSubstring(a)) 26 | 27 | -------------------------------------------------------------------------------- /interview-list/230729-Shein/shein.md: -------------------------------------------------------------------------------- 1 | 对于五个样本点, 真实 11000, 预测概率 0.4 0.8 0.2 0.4 0.5, 求AUC 2 | 3 | AUC, 即 Area under curve, 是ROC曲线 (receiver operating characteristic curve) 曲线下方的面积. 其横坐标是 FPR(false positive rate, 负样本有多少被误召回了), 纵坐标是 TPR(true positive rate, 也就是正样本召回率recall). 4 | 除了画出曲线计算下方面积之外, 我们可以证明, 若定义「排序损失」l 为所有正负样本对中, 正样本得分更小的概率, 则 AUC = 1 - l. 5 | 本题中, 有 l = 1/(2*3) * (1 + .5) = 0.25. 因此, 有 AUC = 0.75. 6 | 7 | -------------------------------------------------------------------------------- /interview-list/230806-Mihayou/1.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 8 7 6 3 | 2 3 4 4 | 1 2 3 -------------------------------------------------------------------------------- /interview-list/230806-Mihayou/2.sh: -------------------------------------------------------------------------------- 1 | 4 5 2 | 6 8 2 3 3 | FFWI 4 | # 14 -------------------------------------------------------------------------------- /interview-list/230806-Mihayou/3.sh: -------------------------------------------------------------------------------- 1 | 5 3 2 | 1 2 3 | 1 3 4 | 3 4 5 | 5 1 -------------------------------------------------------------------------------- /interview-list/230812-Meituan/1.py: -------------------------------------------------------------------------------- 1 | """ 检查是否相邻 2 | """ 3 | 4 | n = int(input()) 5 | arr = list(map(int, input().split())) 6 | a,b = map(int, input().split()) 7 | if abs(arr.index(a)-arr.index(b)) == 1: 8 | print('Yes') 9 | else: 10 | print('No') -------------------------------------------------------------------------------- /interview-list/230812-Meituan/1.sh: -------------------------------------------------------------------------------- 1 | 4 2 | 1 4 2 3 3 | 2 4 4 | # Yes 5 | -------------------------------------------------------------------------------- /interview-list/230812-Meituan/2.py: -------------------------------------------------------------------------------- 1 | """ 给定一个环, 两点最小距离 """ 2 | n = int(input()) 3 | arr = list(map(int, input().split())) 4 | a,b = map(int, input().split()) 5 | s = sum(arr) 6 | a,b = sorted((a-1,b-1)) 7 | d1 = sum(arr[a:b]) 8 | ans = min(d1, s-d1) 9 | print(ans) -------------------------------------------------------------------------------- /interview-list/230812-Meituan/2.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 1 2 2 3 | 1 3 4 | # 2 -------------------------------------------------------------------------------- /interview-list/230812-Meituan/3.py: -------------------------------------------------------------------------------- 1 | """ 对一个矩形切成两块, 求两部分和之差的最小值 2 | 限制: n,m 1e3 3 | """ 4 | n,m = map(int, input().split()) 5 | arr = [list(map(int, input().split())) for _ in range(n)] 6 | 7 | def f(arr): 8 | """ 找到一个序列的最优分割 """ 9 | s = sum(arr) 10 | acc = 0 11 | ans = s 12 | for i,x in enumerate(arr): 13 | acc += x 14 | ans = min(ans, abs(s-2*acc)) 15 | return ans 16 | 17 | srows = [sum(r) for r in arr] 18 | scols = [sum(c) for c in zip(*arr)] 19 | print(min(f(srows), f(scols))) -------------------------------------------------------------------------------- /interview-list/230812-Meituan/3.sh: -------------------------------------------------------------------------------- 1 | 2 3 2 | 1 1 4 3 | 5 1 4 4 | # 0 -------------------------------------------------------------------------------- /interview-list/230812-Meituan/4.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 12 3 | 1 2 4 | 2 3 5 | # 2 -------------------------------------------------------------------------------- /interview-list/230822-pdd/1.py: -------------------------------------------------------------------------------- 1 | """ 对于一个字符串, 判断严格进行K次修改是否可变为回文 2 | 若为偶数长度: 非对称数量 <= K 3 | 奇数: 非对称数量 <= K 4 | """ 5 | 6 | def check(s: str, k:int): 7 | n = len(s) 8 | acc = 0 9 | for i in range(n//2): 10 | if s[i]!=s[n-1-i]: acc += 1 11 | return acc<=k 12 | 13 | n = int(input()) 14 | for _ in range(n): 15 | s = input().strip() 16 | k = int(input()) 17 | if check(s, k): 18 | print("YES") 19 | else: print("NO") 20 | 21 | 22 | -------------------------------------------------------------------------------- /interview-list/230822-pdd/1.sh: -------------------------------------------------------------------------------- 1 | 3 2 | voc 3 | 2 4 | slad 5 | 1 6 | glwllsyflr 7 | 2 8 | # YES 9 | # NO 10 | # NO -------------------------------------------------------------------------------- /interview-list/230822-pdd/2.sh: -------------------------------------------------------------------------------- 1 | 4 2 | # 8 -------------------------------------------------------------------------------- /interview-list/230822-pdd/3.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 7 7 3 | 4 2 2 5 6 12 3 4 | 8 5 5 | 1 6 4 9 14 19 24 29 6 | 15 11 7 | 2 6 7 11 12 12 12 21 22 26 26 27 100 100 100 8 | 9 | # 3 10 | # 2 11 | # 6 -------------------------------------------------------------------------------- /interview-list/230822-pdd/4.sh: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 1 2 2 4 | 6 17 7 5 | 3 6 | 20 7 19 7 | 14 19 3 8 | 9 | # 1 10 | # 0 11 | 12 | 1 13 | 5 14 | 12 8 7 7 7 15 | 9 12 14 14 11 16 | # 2 -------------------------------------------------------------------------------- /interview-list/230827-Jingdong/1.py: -------------------------------------------------------------------------------- 1 | """ n种商品有价格, 每种至少保留一个, 问一个序列最多卖出的价格 2 | 3 | """ 4 | from collections import Counter 5 | n = int(input()) 6 | goods = {} 7 | for _ in range(n): 8 | name,price = input().split() 9 | goods[name] = int(price) 10 | m = int(input()) 11 | goodsHave = input().split() 12 | cnt = Counter(goodsHave) 13 | ans = 0 14 | for n,c in cnt.items(): 15 | if n in goods: 16 | ans += (c-1) * goods[n] 17 | print(ans) 18 | 19 | 20 | -------------------------------------------------------------------------------- /interview-list/230827-Jingdong/1.sh: -------------------------------------------------------------------------------- 1 | 3 2 | dragonball 10000 3 | demontears 3000 4 | elfblood 5000 5 | 6 6 | elfblood elfblood berry demontears elfblood demontears 7 | # 1300 8 | 9 | -------------------------------------------------------------------------------- /interview-list/230827-Jingdong/2.sh: -------------------------------------------------------------------------------- 1 | 3 3 2 | .*. 3 | #.# 4 | #M. 5 | -------------------------------------------------------------------------------- /interview-list/230827-Jingdong/3.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230827-Jingdong/3.py -------------------------------------------------------------------------------- /interview-list/230827-Jingdong/3.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230827-Jingdong/3.sh -------------------------------------------------------------------------------- /interview-list/230909-美团/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | a -> bc 3 | b -> ca 4 | c -> ab 5 | 操作k次, 最后的结果 6 | """ 7 | s = input() 8 | k = int(input()) 9 | for _ in range(k): 10 | r = "" 11 | for c in s: 12 | if c == 'a': 13 | r += 'bc' 14 | elif c == 'b': 15 | r += 'ca' 16 | else: 17 | r += 'ab' 18 | s = r 19 | print(s) 20 | -------------------------------------------------------------------------------- /interview-list/230909-美团/1.sh: -------------------------------------------------------------------------------- 1 | abc 2 | 2 3 | # caababbcbcca -------------------------------------------------------------------------------- /interview-list/230909-美团/2.py: -------------------------------------------------------------------------------- 1 | """ 2 | 对数组求和, 可以改变其中一个数字的符号, 但是前缀不能是负数. 求最大和 3 | 前缀和, 求最大可以减掉的数字 4 | """ 5 | n = int(input()) 6 | arr = list(map(int, input().split())) 7 | s = sum(arr) 8 | mx = -1 9 | acc = 0 10 | for i,x in enumerate(arr): 11 | if x<=acc: 12 | mx = max(mx, x) 13 | acc += x 14 | if mx==-1: 15 | print(-1) 16 | else: 17 | print(s - 2*mx) 18 | -------------------------------------------------------------------------------- /interview-list/230909-美团/2.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 3 2 1 3 | # 2 4 | 3 5 | 1 2 4 6 | # -1 -------------------------------------------------------------------------------- /interview-list/230909-美团/3.py: -------------------------------------------------------------------------------- 1 | """ 2 | 对于一个递增数组, 计算每个元素的差值, 这些差值的不同数量定义为「差异值」, 对于n个数字, 最大限制为m, 求最大的「差异值」 3 | 限制: n,m 1e5 4 | """ 5 | n,m = map(int, input().split()) 6 | def check(k): 7 | diff = (1+k)*k//2 8 | return m >= diff + n - k 9 | l,r = 0,n-1 10 | mx = 0 11 | while l<=r: 12 | mid = (l+r)//2 13 | if check(mid): 14 | mx = mid 15 | l = mid+1 16 | else: 17 | r = mid-1 18 | acc = 1 19 | ans = [1] 20 | for i in range(mx): 21 | acc += i+1 22 | ans.append(acc) 23 | for i in range(n-mx-1): 24 | acc += 1 25 | ans.append(acc) 26 | print(*ans) 27 | -------------------------------------------------------------------------------- /interview-list/230909-美团/3.sh: -------------------------------------------------------------------------------- 1 | 4 12 2 | -------------------------------------------------------------------------------- /interview-list/230909-美团/4.py: -------------------------------------------------------------------------------- 1 | """ TODO: 复杂度不够 2 | 定义数组的权重为, 任意两个数的异或之和. 3 | 所有 连续子数组 的权值和是多少. 答案取模. 4 | 限制: n 1e5 5 | 思路0: 暴力, O(n^2) 6 | 考虑 i,j 两个位置的元素, 它们会被计算多少次异或值? 7 | 此时, 子数组一定包含 [i...j] 这个区间, 再遍历所有, 一共计数 (i+1)*(n-j) 次 8 | """ 9 | n = int(input()) 10 | arr = list(map(int, input().split())) 11 | mod = 10**9+7 12 | 13 | def brust(arr): 14 | n = len(arr) 15 | ans = 0 16 | for i in range(len(arr)): 17 | for j in range(i+1, len(arr)): 18 | ans += (arr[i]^arr[j]) * (i+1) * (n-j) 19 | ans %= mod 20 | return ans 21 | print(brust(arr)) -------------------------------------------------------------------------------- /interview-list/230909-美团/4.sh: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 1 2 3 | # 28 -------------------------------------------------------------------------------- /interview-list/230909-面试题/230425-deer-Meituan.py: -------------------------------------------------------------------------------- 1 | """ 2 | 生成括号 3 | """ 4 | -------------------------------------------------------------------------------- /interview-list/230910-Tencent/1.sh: -------------------------------------------------------------------------------- 1 | 3 2 | 1.0 1.0 0.5 3 | 1.0 1.0 0.25 4 | 0.5 0.25 2.0 5 | 1.0 1.0 1.0 6 | # 2.54 7 | -------------------------------------------------------------------------------- /interview-list/230910-Tencent/2.py: -------------------------------------------------------------------------------- 1 | """ 2 | 对于共n个柱子, 给定 first,last 的高度, 高度差距最多为1, 问可能的最大高度. 3 | """ 4 | 5 | def f(): 6 | n, first, last = map(int, input().split()) 7 | if first>last: 8 | first, last = last, first 9 | if last - first > n-1: 10 | print(-1) 11 | return 12 | x = (last-first +n-1) // 2 13 | print(first+x) 14 | 15 | n = int(input()) 16 | for _ in range(n): 17 | f() 18 | -------------------------------------------------------------------------------- /interview-list/230910-Tencent/2.sh: -------------------------------------------------------------------------------- 1 | 5 2 | 2 1 1 3 | 3 1 1 4 | 5 3 2 5 | 5 1 100 6 | 4 1 4 -------------------------------------------------------------------------------- /interview-list/230910-Tencent/3.sh: -------------------------------------------------------------------------------- 1 | 3 2 2 | aba 3 | cba 4 | cbc 5 | 2 1 3 6 | # 1 7 | # 2 8 | # 1 9 | # 0 -------------------------------------------------------------------------------- /interview-list/230912-Baidu/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 贪心得到 1,2,3... 序列需要删除多少元素 3 | """ 4 | n = int(input()) 5 | arr = list(map(int, input().split())) 6 | acc = 1 7 | ans = 0 8 | for x in arr: 9 | if x==acc: 10 | acc += 1 11 | else: 12 | ans += 1 13 | if acc==1: 14 | print(-1) 15 | else: print(ans) 16 | -------------------------------------------------------------------------------- /interview-list/230912-Baidu/1.sh: -------------------------------------------------------------------------------- 1 | 5 2 | 1 4 2 3 5 3 | # 2 4 | 3 5 | 3 3 2 6 | # -1 -------------------------------------------------------------------------------- /interview-list/230912-Baidu/2.sh: -------------------------------------------------------------------------------- 1 | 3 2 2 | 1 9 3 3 | 2 7 8 4 | # 7 5 | # 三条边的权重分别为 13,7,8 -------------------------------------------------------------------------------- /interview-list/230912-Baidu/3.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230912-Baidu/3.py -------------------------------------------------------------------------------- /interview-list/230912-Baidu/3.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230912-Baidu/3.sh -------------------------------------------------------------------------------- /interview-list/230926-IYQ/ML+数学题.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230926-IYQ/ML+数学题.md -------------------------------------------------------------------------------- /interview-list/230926-ant-蚂蚁/3.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/230926-ant-蚂蚁/3.sh -------------------------------------------------------------------------------- /interview-list/231108-huawei/1.sh: -------------------------------------------------------------------------------- 1 | 5 2 | 1 90 3 | 2 91 4 | 3 95 5 | 4 96 6 | 5 100 7 | # 1 2 8 | # 3 4 9 | 10 | 5 11 | 1 90 12 | 2 91 13 | 3 92 14 | 4 86 15 | 5 87 16 | # 1 2 17 | # 2 3 18 | # 4 5 19 | 20 | 21 | 5 22 | 1 90 23 | 2 90 24 | 3 90 25 | 4 100 26 | 5 100 27 | # 1 2 28 | # 1 3 29 | # 2 3 -------------------------------------------------------------------------------- /interview-list/231108-huawei/2.sh: -------------------------------------------------------------------------------- 1 | 1 2 | prefix /rest/service/message 3 | /rest/service/message/publish 4 | /rest/view 5 | # prefix /rest/service/message 6 | # (null) 7 | 8 | 2 9 | prefix /rest/service/message 10 | exact /rest/service/message/publish 11 | /rest/service/message/publish 12 | # exact /rest/service/message/publish -------------------------------------------------------------------------------- /interview-list/231108-huawei/3.sh: -------------------------------------------------------------------------------- 1 | 7 2 | 1 2 3 4 5 6 6 3 | 15 4 | # 5 5 | 6 | 7 7 | 1 2 3 3 4 5 9 8 | 19 9 | # 5 10 | 11 | 7 12 | 1 2 3 0 4 5 9 13 | 19 14 | # 6 15 | 16 | 1 17 | 1 18 | 0 -------------------------------------------------------------------------------- /interview-list/231108-华泰/1.py: -------------------------------------------------------------------------------- 1 | """ 10转为r进制数值 """ 2 | import string 3 | i,r = map(int, input().split()) 4 | dmap = list(range(10)) + list(string.ascii_uppercase) 5 | ans = [] 6 | while i: 7 | ans.append(dmap[i%r]) 8 | i //= r 9 | print(''.join(map(str, ans[::-1]))) -------------------------------------------------------------------------------- /interview-list/231108-华泰/2.py: -------------------------------------------------------------------------------- 1 | """ 2 | 大小为k的滑窗, 依次计算最大值. 3 | 思路1: 利用堆, 记录时间戳 4 | """ 5 | import heapq 6 | 7 | arr = list(map(int, input().split())) 8 | k = int(input()) 9 | arr = [-i for i in arr] 10 | h = [] 11 | ans = [] 12 | for i in range(k-1): 13 | heapq.heappush(h, (arr[i], i)) 14 | for i in range(k-1,len(arr)): 15 | heapq.heappush(h, (arr[i], i)) 16 | while h[0][1] <= i-k: 17 | heapq.heappop(h) 18 | ans.append(-h[0][0]) 19 | print(ans) 20 | -------------------------------------------------------------------------------- /interview-list/231109-shopee/1.py: -------------------------------------------------------------------------------- 1 | """ 找出长度为k的字符串中, 元音字母的最大数量 2 | s = "tryhard", k = 4 3 | """ 4 | 5 | vowels = "aeiou" 6 | 7 | s, k = input().strip().split(',') 8 | k = int(k.split('=')[1]) 9 | s = s.split('=')[1].strip().strip('"') 10 | cnt = mx = 0 11 | for i in range(k): 12 | if s[i] in vowels: 13 | cnt += 1 14 | mx = cnt 15 | for i in range(k,len(s)): 16 | if s[i] in vowels: 17 | cnt += 1 18 | if s[i-k] in vowels: 19 | cnt -= 1 20 | mx = max(mx, cnt) 21 | print(mx) 22 | 23 | -------------------------------------------------------------------------------- /interview-list/231109-shopee/1.sh: -------------------------------------------------------------------------------- 1 | s = "tryhard", k = 4 2 | # 1 -------------------------------------------------------------------------------- /interview-list/231109-shopee/2.sh: -------------------------------------------------------------------------------- 1 | nums = [1,2,3,1], k = 3, t = 0 2 | # true 3 | nums = [1,0,1,1], k = 1, t = 2 4 | # true 5 | nums = [1,5,9,1,5,9], k = 2, t = 3 6 | # false 7 | 8 | 9 | nums = [0], k = 2, t = 3 10 | -------------------------------------------------------------------------------- /interview-list/231109-shopee/3.py: -------------------------------------------------------------------------------- 1 | """ 2 | 给定一颗二叉树, 输出层序遍历的结果. 3 | 4 | input: {3,9,20,#,#,15,7} 5 | output: [[3],[9,20],[15,7]] 6 | """ 7 | nodes = input().strip().strip('{').strip('}').split(',') 8 | n = len(nodes) 9 | idx = 0; length = 1 10 | ans = [] 11 | while idx < n: 12 | layer = nodes[idx:idx+length] 13 | layer = [int(x) for x in layer if x != '#'] 14 | ans.append(layer) 15 | idx += length 16 | length <<= 1 17 | ans = str(ans).replace(' ', '') 18 | print(ans) 19 | -------------------------------------------------------------------------------- /interview-list/231109-shopee/3.sh: -------------------------------------------------------------------------------- 1 | {3,9,20,#,#,15,7} 2 | # [[3],[9,20],[15,7]] -------------------------------------------------------------------------------- /interview-list/240317-小红书-test/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | n = int(input()) 4 | ans = 2 / n/(n-1) 5 | print(f"{ans:.10f}") 6 | -------------------------------------------------------------------------------- /interview-list/240317-小红书-test/2.py: -------------------------------------------------------------------------------- 1 | """ 2 | #P1710. 2024.3.17-小红书-第二题-推荐算法 3 | https://codefun2000.com/p/P1710 4 | """ 5 | from collections import defaultdict 6 | n,q = map(int, input().split()) 7 | keywords = set(input().split()) 8 | num2list = defaultdict(list) 9 | for _ in range(n): 10 | name, _ = input().split() 11 | keys = set(input().split()) 12 | num_inter = len(keywords & keys) 13 | num2list[num_inter].append(name) 14 | for num in sorted(num2list.keys(), reverse=True): 15 | for name in num2list[num]: 16 | print(name) 17 | 18 | -------------------------------------------------------------------------------- /interview-list/240324-小红书/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | """ 4 | n = int(input()) 5 | s = set() 6 | for _ in range(n): 7 | ii = input().strip() 8 | if ii not in s: 9 | print(ii) 10 | s.add(ii) 11 | 12 | -------------------------------------------------------------------------------- /interview-list/240324-小红书/1.sh: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /interview-list/240324-小红书/2.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240324-小红书/2.sh -------------------------------------------------------------------------------- /interview-list/240324-小红书/3.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240324-小红书/3.sh -------------------------------------------------------------------------------- /interview-list/240330-Meituan-test/1.sh: -------------------------------------------------------------------------------- 1 | 5 3 5 2 | 1 2 3 | 2 3 4 | 4 5 5 | 1 1 5 6 | 2 1 3 7 | 2 1 4 8 | 1 1 2 9 | 2 1 3 10 | -------------------------------------------------------------------------------- /interview-list/240330-Meituan-test/2.py: -------------------------------------------------------------------------------- 1 | """ 2 | 24春招第一场 3 | https://www.nowcoder.com/exam/test/79025101/detail?pid=55750543 4 | 5 | T5 小美的区间删除 6 | 在保证剩余的数字乘积至少有k个0的情况下, 删除数组区间的方案数量 7 | 限制: n,k 1e5; x 1e9 8 | 思路1: #滑动窗口 9 | 如何满足至少k个0? 只需要考虑剩余数字的 2/5 的出现次数! 10 | 11 | 5 2 12 | 2 5 3 4 20 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /interview-list/240330-Meituan-test/2.sh: -------------------------------------------------------------------------------- 1 | 5 2 2 | 2 5 3 4 20 3 | -------------------------------------------------------------------------------- /interview-list/240330-Meituan-test/3.py: -------------------------------------------------------------------------------- 1 | """ 2 | 24秋招第二场 3 | https://www.nowcoder.com/exam/test/79025466/detail?pid=52007812 4 | 5 | T2. 小美的数组操作 6 | 对于一个数组, 可以进行一个+1 一个-1的操作. 最终使得数组的「众数」出现的次数尽可能多 (有更多相同数字). 问最小的操作次数是多少. 7 | 思路1: #贪心 8 | 众数只可能是 n, n-1 分类考虑 9 | 对于n-1的情况, 肯定是去掉最大/最小的数字, 其他元素变为均值!! 10 | 11 | """ -------------------------------------------------------------------------------- /interview-list/240330-Meituan-test/3.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240330-Meituan-test/3.sh -------------------------------------------------------------------------------- /interview-list/240330-Meituan-test/4.py: -------------------------------------------------------------------------------- 1 | """ 2 | 24秋招第二场 3 | https://www.nowcoder.com/exam/test/79025466/detail?pid=52007812 4 | T6. 小美的数组构造 5 | 给定一个数组a, 要求构造数组b, 使得sum(b)==sum(a) 并且对应位置的元素各不相等 6 | 限制: sum 500, n 100 对于结果取模 7 | 思路1: #DP 8 | 定义 f[i,s] 表示前i个元素符合条件, 并且和为s的方案数量. 9 | 转移: f[i,s] = sum{ f[i-1,s-k] | k=1...s-i 并且!=a[i] } 10 | """ 11 | mod = 10**9+7 12 | -------------------------------------------------------------------------------- /interview-list/240330-Meituan-test/4.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240330-Meituan-test/4.sh -------------------------------------------------------------------------------- /interview-list/240330-Meituan-test/readmd.md: -------------------------------------------------------------------------------- 1 | 挺难的 orz 2 | 3 | 0323: https://mp.weixin.qq.com/s/SCtnNpgo5R0bULIOGdjsEg 4 | 0316: https://mp.weixin.qq.com/s/vOmvwV5TcgVKJZq7niqpog 5 | -------------------------------------------------------------------------------- /interview-list/240330-Meituan/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 441 1 -20 3 | # 153 134 154 4 | """ 5 | 6 | k,x,y = map(int, input().split()) 7 | a = (k+x-y)//3 8 | res = [a-x,a+y,a] 9 | print(" ".join(map(str, res))) -------------------------------------------------------------------------------- /interview-list/240330-Meituan/1.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240330-Meituan/1.sh -------------------------------------------------------------------------------- /interview-list/240330-Meituan/2.py: -------------------------------------------------------------------------------- 1 | """ 2 | 5 3 | 1 3 2 5 4 4 | # 5 6 5 10 8 5 | """ 6 | n = int(input()) 7 | arr = list(map(int, input().split())) 8 | mx = max(arr) 9 | res = [mx] * n 10 | for i,x in enumerate(arr): 11 | if 2*x > mx: 12 | res[i] = 2*x 13 | print(" ".join(map(str, res))) -------------------------------------------------------------------------------- /interview-list/240330-Meituan/2.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240330-Meituan/2.sh -------------------------------------------------------------------------------- /interview-list/240330-Meituan/3.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240330-Meituan/3.sh -------------------------------------------------------------------------------- /interview-list/240330-Meituan/4.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240330-Meituan/4.sh -------------------------------------------------------------------------------- /interview-list/240330-Meituan/5.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/240330-Meituan/5.sh -------------------------------------------------------------------------------- /interview-list/240406-Meituan/1.py: -------------------------------------------------------------------------------- 1 | s = input().strip() 2 | t = 'meituan' 3 | ans = 0 4 | for c1,c2 in zip(s,t): 5 | ans += c1 != c2 6 | print(ans) -------------------------------------------------------------------------------- /interview-list/240406-Meituan/3_gen.py: -------------------------------------------------------------------------------- 1 | from itertools import accumulate 2 | n = 5 3 | arr = [1,2,3,4,5] 4 | i,j = 1,3 5 | arr1 = arr[:] 6 | arr1.pop(i) 7 | acc1 = list(accumulate(arr1)) 8 | arr2 = arr[:] 9 | arr2.pop(j) 10 | acc2 = list(accumulate(arr2)) 11 | print(n) 12 | print(" ".join(map(str, acc1))) 13 | print(" ".join(map(str, acc2))) -------------------------------------------------------------------------------- /interview-list/240407-小红书/1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 有n个粉丝, (x,y) 的权重分别为 (1,2), 根据 (score, y, -id) 的顺序逆序排列, 返回前k个 3 | 4 | 4 2 5 | 1 2 6 | 2 1 7 | 3 0 8 | 1 3 9 | # 1 4 10 | 11 | """ 12 | n,k = map(int, input().split()) 13 | fans = [] 14 | for i in range(1,n+1): 15 | x,y = map(int, input().split()) 16 | s = x + 2*y 17 | fans.append((s,y,-i)) 18 | fans.sort(reverse=True) 19 | ans = [-i[2] for i in fans[:k]] 20 | ans.sort() 21 | print(" ".join(map(str, ans))) -------------------------------------------------------------------------------- /interview-list/999999-template/1.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/999999-template/1.py -------------------------------------------------------------------------------- /interview-list/999999-template/2.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/999999-template/2.py -------------------------------------------------------------------------------- /interview-list/999999-template/3.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/999999-template/3.py -------------------------------------------------------------------------------- /interview-list/company-readme.md: -------------------------------------------------------------------------------- 1 | LeetCode 求职: 2 | 3 | -------------------------------------------------------------------------------- /interview-list/misc-interview/1.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/interview-list/misc-interview/1.sh -------------------------------------------------------------------------------- /interview-list/misc-interview/2.py: -------------------------------------------------------------------------------- 1 | """ 二叉树的非递归后序遍历 2 | 3 | """ 4 | 5 | class Node: 6 | def __init__(self) -> None: 7 | self.val = None 8 | self.left = None 9 | self.right = None 10 | 11 | def dfs(node): 12 | if not node: 13 | return 14 | stack = [] 15 | stack.append(node) 16 | while stack: 17 | node = stack.pop() 18 | print(node.val) 19 | if node.left: 20 | stack.append(node.left) 21 | if node.right: 22 | stack.append(node.right) 23 | -------------------------------------------------------------------------------- /interview-list/misc-interview/2209-hulu-hard.md: -------------------------------------------------------------------------------- 1 | 2 | [2022 官方放出来的题](https://mp.weixin.qq.com/s/4PUjgRnD3fgSN-hh52pXag) 就笑看. 3 | 4 | ### 人间 “雨人” 5 | 6 | 要求找到 [A,B] 范围内, 满足所有数位之和 %N = 0 的数字个数. 7 | 限制: N 100; A,B 1e11 8 | 9 | 提示: 子问题, 求不大于x的满足条件的数量. 10 | 思路1: 数位DP, 令 `f[i][j]` 表示不超过 m 的情况下,前 i 位数的和模 N 为 j 的数的个数. 11 | -------------------------------------------------------------------------------- /interview-list/misc-interview/2303-byte.md: -------------------------------------------------------------------------------- 1 | 2 | 自我介绍: 3 | KG的推荐算法? KGAT, KGIN. 4 | RippleNet 节点数量比较多的情况? 5 | 采样策略. 预测的时候? 训练预测不一致的问题; 模型的不稳定性 6 | 基于元路径? 7 | 论文: 对于物品进行 item-CF 得到聚类 8 | 为什么用聚类的结果而不用标签 9 | 有哪些相似度? item-CF 10 | cos 相似度, 为什么要归一化 11 | 12 | B站 13 | wtr的训练trick? 14 | poso的作用? 15 | 16 | 集成学习 17 | bagging: RF 18 | boosting: GBDT 19 | 误差 vs 方差 20 | 21 | 树模型: GBDT的分裂准则 22 | 23 | 两道算法题: 1] topK的元素; 2] 二叉树的非递归后序遍历 24 | -------------------------------------------------------------------------------- /interview-list/misc-interview/2303-byte.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | 4 | 思路1: #DP 记 f[i,j] 表示是否为回文串, 累计所有的 f[i,j] 即为答案 5 | 递推公式: f[i,j] = f[i+1,j-1] and s[i] == s[j] 6 | """ 7 | 8 | from functools import cache 9 | def count(s: str)->int: 10 | n = len(s) 11 | @cache 12 | def f(i,j): 13 | if i >= j: return True 14 | return f(i+1,j-1) and s[i] == s[j] 15 | return sum(f(i,j) for i in range(n) for j in range(i,n)) 16 | 17 | print(count('abbc')) # 3 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /interview-list/misc-interview/230802.py: -------------------------------------------------------------------------------- 1 | """ 2 | 定义操作A为合并相邻的重复元素, 分数为所得到的数组长度. 需要将一个长度为n的数组切分为k块, 问可得的最大分数之和. 3 | 限制: n 1e5 4 | 思路1: #贪心 注意到, 一个切分操作最多增加整体分数值1 5 | 因此, 记整体的分数为a, 统计最多容许进行切分的个数即可 6 | 7 | 8 3 8 | 1 1 1 2 2 3 3 1 9 | # 6 10 | 1 4 11 | 1 1 1 1 1 1 1 1 12 | # 3 13 | """ 14 | 15 | n,k = map(int, input().split()) 16 | arr = list(map(int, input().split())) 17 | 18 | a = b = 0 19 | pre = -1 20 | for x in arr: 21 | if x!=pre: 22 | a += 1 23 | else: 24 | b += 1 25 | pre = x 26 | 27 | print(a + min(b, k-1)) -------------------------------------------------------------------------------- /interview-list/others/Newcoder-Huawei/计算某字母出现次数.py: -------------------------------------------------------------------------------- 1 | """ 2 | 写出一个程序,接受一个由字母、数字和空格组成的字符串,和一个字母,然后输出输入字符串中该字母的出现次数。不区分大小写。 3 | 4 | ABCabc 5 | A 6 | 7 | 2 8 | """ 9 | 10 | import sys 11 | s = sys.stdin.readline().strip() 12 | c = sys.stdin.readline().strip() 13 | 14 | base = ord('A') 15 | if ord(c) 停更于2020 #todo 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /java/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.project.sourcePaths": [ 3 | "01.hello", 4 | "src" 5 | ], 6 | "workbench.colorCustomizations": { 7 | "activityBar.background": "#1A3318", 8 | "titleBar.activeBackground": "#254721", 9 | "titleBar.activeForeground": "#F6FBF6" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java/01.hello/Hello.java: -------------------------------------------------------------------------------- 1 | public class Hello{ 2 | public static void main(String[] args) { 3 | System.out.println("hello world!"); 4 | } 5 | } -------------------------------------------------------------------------------- /java/Maven_/maven-hello/src/main/java/com/itranswarp/learnjava/Main.java: -------------------------------------------------------------------------------- 1 | package com.itranswarp.learnjava; 2 | 3 | import org.slf4j.LoggerFactory; 4 | 5 | /** 6 | * App entry for Maven project. 7 | * 8 | * @author liaoxuefeng 9 | */ 10 | public class Main { 11 | 12 | public static void main(String[] args) throws Exception { 13 | var logger = LoggerFactory.getLogger(Main.class); 14 | logger.info("start application..."); 15 | for (int i = 1; i <= 10; i++) { 16 | Thread.sleep(100); 17 | logger.warn("begin task {}...", i); 18 | } 19 | logger.info("done."); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /java/Maven_/maven-hello/src/test/java/com/itranswarp/learnjava/MainTest.java: -------------------------------------------------------------------------------- 1 | package com.itranswarp.learnjava; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | public class MainTest { 8 | 9 | @Test 10 | void test() { 11 | int abs = Math.abs(-123); 12 | assertEquals(123, abs); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /java/Maven_/maven-plugin/src/main/java/com/itranswarp/learnjava/Main.java: -------------------------------------------------------------------------------- 1 | package com.itranswarp.learnjava; 2 | 3 | import org.slf4j.LoggerFactory; 4 | 5 | /** 6 | * App entry for Maven project. 7 | * 8 | * @author liaoxuefeng 9 | */ 10 | public class Main { 11 | 12 | public static void main(String[] args) throws Exception { 13 | var logger = LoggerFactory.getLogger(Main.class); 14 | logger.info("start application..."); 15 | for (int i = 1; i <= 10; i++) { 16 | Thread.sleep(100); 17 | logger.warn("begin task {}...", i); 18 | } 19 | logger.info("done."); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /java/javaa/ListNode.java: -------------------------------------------------------------------------------- 1 | package javaa; 2 | 3 | public class ListNode { 4 | int val; 5 | ListNode next; 6 | ListNode() {} 7 | ListNode(int val) { this.val = val; } 8 | ListNode(int val, ListNode next) { this.val = val; this.next = next; } 9 | } 10 | -------------------------------------------------------------------------------- /java/src/basic/ExecFloat.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | 4 | public class ExecFloat { 5 | 6 | public static void main(String[] args) { 7 | // x*x + 3*x - 4 = 0 8 | double a = 1.0; 9 | double b = 3.0; 10 | double c = -4.0; 11 | // 求平方根可用 Math.sqrt(): 12 | // double x = Math.sqrt(2)); // ==> 1.414 13 | double rr = Math.sqrt(b*b - 4*a*c); 14 | double r1 = (-b + rr) / (2*a); 15 | double r2 = (-b - rr) / (2*a); 16 | System.out.println(r1 + ", " + r2); 17 | System.out.println(r1 == 1 && r2 == -4 ? "测试通过" : "测试失败"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /java/src/basic/JoinChar.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | 4 | /** 5 | * char and String 6 | */ 7 | public class JoinChar { 8 | 9 | public static void main(String[] args) { 10 | // 请将下面一组int值视为字符的Unicode码,把它们拼成一个字符串: 11 | int a = 72; 12 | int b = 105; 13 | int c = 65281; 14 | String s = "" + (char)a + (char)b + (char)c; // 类型转换 15 | System.out.println(s); 16 | s = Character.toString(a) + Character.toString(b) + Character.toString(c); 17 | System.out.println(s); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /java/src/basic/PrimaryStudent.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | 4 | public class PrimaryStudent { 5 | public static void main(String[] args) { 6 | int age = 7; 7 | // primary student的定义: 6~12岁 8 | boolean isPrimaryStudent = age>=6 && age<=12; 9 | System.out.println(isPrimaryStudent ? "Yes" : "No"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java/src/basic/SumOfInteger.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | 4 | /** 5 | * Sum of integers. 6 | */ 7 | public class SumOfInteger { 8 | 9 | public static void main(String[] args) { 10 | int n = 100; 11 | int sum = 0; 12 | for (int i=1; i<= n; i++) { 13 | sum += i; 14 | } 15 | System.out.println(sum); 16 | } 17 | 18 | 19 | } -------------------------------------------------------------------------------- /java/src/oop/method/Main.java: -------------------------------------------------------------------------------- 1 | package oop.method; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | Person ming = new Person(); 6 | ming.setName("小明"); 7 | System.out.println(ming.getName()); 8 | 9 | ming.setAge(12); 10 | System.out.println(ming.getAge()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java/src/oop/method/Person.java: -------------------------------------------------------------------------------- 1 | package oop.method; 2 | 3 | public class Person { 4 | private String name; 5 | private int age; 6 | 7 | public String getName() { 8 | return name; 9 | } 10 | 11 | public void setName(String name) { 12 | this.name = name; 13 | } 14 | 15 | public void setAge(int age) { 16 | this.age = age; 17 | } 18 | 19 | public int getAge() { 20 | return this.age; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /js/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "pwa-node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "skipFiles": ["/**"], 12 | "program": "${workspaceFolder}/first/hello.js" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /js/451-js/media/js-note/2022-02-10-16-16-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/451-js/media/js-note/2022-02-10-16-16-07.png -------------------------------------------------------------------------------- /js/451-js/media/js-note/2022-02-10-16-22-43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/451-js/media/js-note/2022-02-10-16-22-43.png -------------------------------------------------------------------------------- /js/451-js/media/js-note/2022-02-10-16-42-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/451-js/media/js-note/2022-02-10-16-42-39.png -------------------------------------------------------------------------------- /js/451-js/media/js-note/2022-02-10-22-27-30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/451-js/media/js-note/2022-02-10-22-27-30.png -------------------------------------------------------------------------------- /js/Electron/electron.md: -------------------------------------------------------------------------------- 1 | !!! note 2 | see [paper_lib] 3 | 4 | 5 | 6 | Fiddle 的简单结构: A main script, a renderer script, a preload script, and an HTML file. 7 | 8 | - Electron 教程: https://www.electronjs.org/docs/latest/ 9 | -------------------------------------------------------------------------------- /js/from-washu/001-quickstart.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/from-washu/001-quickstart.js -------------------------------------------------------------------------------- /js/from-washu/ReBloom/getStarted.js: -------------------------------------------------------------------------------- 1 | const { BloomFilter } = require('@albert-team/rebloom') 2 | 3 | const main = async () => { 4 | const filter = new BloomFilter('filtername', { 5 | host: 'localhost', 6 | port: 6379, 7 | redisClientOptions: { password: 'scrtpassword' }, 8 | }) 9 | await filter.connect() 10 | 11 | console.log(await filter.add('item0')) // 1 12 | console.log(await filter.exists('item0')) // 1 13 | console.log(await filter.exists('item1')) // 0 14 | 15 | await filter.disconnect() 16 | } 17 | 18 | main().catch((err) => console.error(err)) 19 | -------------------------------------------------------------------------------- /js/from-washu/learn-ElasticSearch/001-quickstart.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/from-washu/learn-ElasticSearch/001-quickstart.js -------------------------------------------------------------------------------- /js/from-washu/learn-ElasticSearch/readme.md: -------------------------------------------------------------------------------- 1 | 2 | quick-start: 来自 ES 中文官方的 Node 教程 [Elasticsearch:应用 Nodejs 来访问 Elasticsearch](https://blog.csdn.net/UbuntuTouch/article/details/100112283) 3 | -------------------------------------------------------------------------------- /js/from-washu/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "learn-js", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": {}, 7 | "keywords": [], 8 | "author": "", 9 | "license": "ISC", 10 | "dependencies": { 11 | "@albert-team/rebloom": "^2.5.0", 12 | "bloomfilter-redis": "^0.1.2", 13 | "ioredis": "^4.26.0", 14 | "mysql2": "^2.2.5", 15 | "redis": "^3.1.1", 16 | "sequelize": "^6.6.2" 17 | } 18 | } -------------------------------------------------------------------------------- /js/node/crypto/hash.js: -------------------------------------------------------------------------------- 1 | const crypto = require("crypto"); 2 | 3 | // sha1, sha256, sha512 4 | const hash = crypto.createHash("md5"); 5 | 6 | hash.update("Hello, world!"); 7 | hash.update("Hello, nodejs!"); 8 | 9 | var r = hash.digest("hex"); 10 | console.log(`md5 hash: ${r}`); // 7e1977739c748beac0c0fd14fd26a544 11 | -------------------------------------------------------------------------------- /js/node/crypto/hmac.js: -------------------------------------------------------------------------------- 1 | const crypto = require('crypto'); 2 | 3 | const hmac = crypto.createHmac('sha256', 'secret-key'); 4 | 5 | hmac.update('Hello, world!'); 6 | hmac.update('Hello, nodejs!'); 7 | 8 | var r = hmac.digest('hex'); 9 | console.log('hmac: ' + r); // 80f7e22570bed1fa3ef683edce5d0890e268e1ca8d1bd0c382bc766f3744be9f 10 | -------------------------------------------------------------------------------- /js/node/crypto/rsa-pub.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkutKlptlsXWe4od+se7M 3 | 0I6xQ7CcKuN+B7LUmT3toMWTThXdfEUjbtkZsQAd/NRw9kCSNkUqFoKHHe1YUEa+ 4 | fhdjdL6rLRL+K9O3hV5EUHL6CykC+UbjxQ4EOi7fScAv7f1g9jAD6vtI+Rml44uU 5 | zCMzhsoToRpYamebnaDLI28/hs7ZVhdcbWX61XZnhhT2hmB4IeWSpRiNU4nyBtdC 6 | rFPS5Ad2m0HPrfqWnELvfw0sT6Hczhtefv9nFcJuqWTBanA0y6i8m5jjXOqO6J5S 7 | /qUgDVRcozt3GEAx0AgpGBRYGnXOMEMNTsiYwsGrAw2VJxX9SjmYmE47XAFaTEYL 8 | 9QIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /js/node/fs/.gitignore: -------------------------------------------------------------------------------- 1 | output.txt 2 | 3 | -------------------------------------------------------------------------------- /js/node/fs/read_image_file_async.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // read from 'sample.png' 4 | 5 | const fs = require('fs'); 6 | 7 | console.log('>>> BEGIN >>>') 8 | 9 | fs.readFile('sample.png', function (err, data) { 10 | if (err) { 11 | console.log(err); 12 | } else { 13 | console.log(data); 14 | console.log(data.length + ' bytes'); 15 | } 16 | }); 17 | 18 | console.log('>>> END >>>') 19 | -------------------------------------------------------------------------------- /js/node/fs/read_image_file_sync.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // read from 'sample.png' 4 | 5 | const fs = require('fs'); 6 | 7 | console.log('>>> BEGIN >>>') 8 | 9 | var data = fs.readFileSync('sample.png'); 10 | console.log(data); 11 | console.log(data.length + ' bytes'); 12 | 13 | console.log('>>> END >>>') 14 | -------------------------------------------------------------------------------- /js/node/fs/read_text_file_async.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // read text from 'sample.txt' 4 | 5 | const fs = require('fs'); 6 | 7 | console.log('>>> BEGIN >>>') 8 | 9 | fs.readFile('sample.txt', 'utf-8', function (err, data) { 10 | if (err) { 11 | console.log(err); 12 | } else { 13 | console.log(data); 14 | } 15 | }); 16 | 17 | console.log('>>> END >>>') 18 | -------------------------------------------------------------------------------- /js/node/fs/read_text_file_sync.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // read text from 'sample.txt' 4 | 5 | const fs = require("fs"); 6 | 7 | console.log(">>> BEGIN >>>"); 8 | 9 | var data = fs.readFileSync("sample.txt", "utf-8"); 10 | console.log(data); 11 | 12 | console.log(">>> END >>>"); 13 | -------------------------------------------------------------------------------- /js/node/fs/sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/node/fs/sample.png -------------------------------------------------------------------------------- /js/node/fs/sample.txt: -------------------------------------------------------------------------------- 1 | Nodejs教程:File I/O is provided by simple wrappers around standard POSIX functions. To use this module do require('fs'). All the methods have asynchronous and synchronous forms. -------------------------------------------------------------------------------- /js/node/fs/use_buffer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // read binary data from 'sample.txt' 4 | 5 | const fs = require('fs'); 6 | 7 | var data = fs.readFileSync('sample.txt') 8 | console.log(data); 9 | console.log(data.length + ' bytes'); 10 | console.log('First three bytes: ' + data[0] + ', ' + data[1] + ', ' + data[2]); 11 | 12 | // Buffer -> String 13 | var text = data.toString('utf-8'); 14 | console.log(text); 15 | 16 | // String -> Buffer 17 | var buf = new Buffer(text, 'utf-8'); 18 | console.log(buf); 19 | -------------------------------------------------------------------------------- /js/node/fs/use_stat.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | 5 | fs.stat('sample.txt', function (err, stat) { 6 | if (err) { 7 | console.log(err); 8 | } else { 9 | console.log('isFile: ' + stat.isFile()); 10 | console.log('isDirectory: ' + stat.isDirectory()); 11 | if (stat.isFile()) { 12 | console.log('size: ' + stat.size); 13 | console.log('birth time: ' + stat.birthtime); 14 | console.log('modified time: ' + stat.mtime); 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /js/node/fs/write_text_file_async.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // write text to 'output.txt' 4 | 5 | const fs = require('fs'); 6 | 7 | console.log('>>> BEGIN >>>') 8 | 9 | var data = 'Hello, Node.js'; 10 | fs.writeFile('output.txt', data, function (err) { 11 | if (err) { 12 | console.log(err); 13 | } else { 14 | console.log('ok.'); 15 | } 16 | }); 17 | 18 | console.log('>>> END >>>') 19 | -------------------------------------------------------------------------------- /js/node/fs/write_text_file_sync.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // write text to 'output.txt' 4 | 5 | const fs = require('fs'); 6 | 7 | console.log('>>> BEGIN >>>') 8 | 9 | var data = 'Hello, Node.js'; 10 | fs.writeFileSync('output.txt', data); 11 | 12 | console.log('>>> END >>>') 13 | -------------------------------------------------------------------------------- /js/node/http/hello.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // a simple http server that always display 'Hello, world!' 4 | 5 | var http = require('http'); 6 | 7 | var server = http.createServer(function (request, response) { 8 | console.log(request.method + ': ' + request.url); 9 | response.writeHead(200, {'Content-Type': 'text/html'}); 10 | response.end('

Hello world!

'); 11 | }); 12 | 13 | server.listen(8080); 14 | 15 | console.log('Server is running at http://127.0.0.1:8080/'); 16 | -------------------------------------------------------------------------------- /js/node/http/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/node/http/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /js/node/http/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/node/http/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /js/node/http/static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/js/node/http/static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /js/node/http/urls.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var url = require('url'); 4 | 5 | // parse url: 6 | console.log(url.parse('http://user:pass@host.com:8080/path/to/file?query=string#hash')); 7 | 8 | // parse incomplete url: 9 | console.log(url.parse('/static/js/jquery.js?name=Hello%20world')); 10 | 11 | // construct a url: 12 | console.log(url.format({ 13 | protocol: 'http', 14 | hostname: 'localhost', 15 | pathname: '/static/js', 16 | query: { 17 | name: 'Nodejs', 18 | version: 'v 1.0' 19 | } 20 | })); 21 | -------------------------------------------------------------------------------- /js/node/module/hello.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var s = 'Hello'; 4 | 5 | function greet(name) { 6 | console.log(s + ', ' + name + '!'); 7 | } 8 | 9 | function hi(name) { 10 | console.log('Hi, ' + name + '!'); 11 | } 12 | 13 | function goodbye(name) { 14 | console.log('Goodbye, ' + name + '!'); 15 | } 16 | 17 | module.exports = { 18 | greet: greet, 19 | hi: hi, 20 | goodbye: goodbye 21 | }; 22 | -------------------------------------------------------------------------------- /js/node/module/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const hello = require('./hello'); 4 | 5 | var s = 'Michael'; 6 | 7 | hello.greet(s); 8 | hello.goodbye(s); 9 | -------------------------------------------------------------------------------- /js/node/nodejs.md: -------------------------------------------------------------------------------- 1 | 教程: https://nodejs.org/en/learn/ 2 | -------------------------------------------------------------------------------- /js/node/os/get_os_info.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const os = require('os'); 4 | 5 | console.log('CPU: ' + JSON.stringify(os.cpus())); 6 | 7 | console.log('Network: ' + JSON.stringify(os.networkInterfaces())); 8 | 9 | console.log('Total memory: ' + os.totalmem()); 10 | 11 | console.log('Free memory: ' + os.freemem()); 12 | 13 | console.log('Hostname: ' + os.hostname()); 14 | 15 | console.log('Platform: ' + os.platform()); 16 | 17 | console.log('Temp dir: ' + os.tmpdir()); 18 | 19 | console.log('OS type: ' + os.type()); 20 | 21 | console.log('Uptime: ' + os.uptime()); 22 | -------------------------------------------------------------------------------- /js/node/stream/.gitignore: -------------------------------------------------------------------------------- 1 | copied.txt 2 | output1.txt 3 | output2.txt 4 | 5 | -------------------------------------------------------------------------------- /js/node/stream/copy_file.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // read binary data from 'sample.txt' 4 | 5 | const fs = require('fs'); 6 | 7 | var rs = fs.createReadStream('sample.txt'); 8 | var ws = fs.createWriteStream('copied.txt'); 9 | 10 | rs.pipe(ws); 11 | -------------------------------------------------------------------------------- /js/node/stream/read_stream.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | 5 | var rs = fs.createReadStream('sample.txt', 'utf-8'); 6 | rs.on('data', function (chunk) { 7 | console.log('DATA:') 8 | console.log(chunk); 9 | }); 10 | rs.on('end', function () { 11 | console.log('END'); 12 | }); 13 | rs.on('error', function (err) { 14 | console.log('ERROR: ' + err); 15 | }); 16 | -------------------------------------------------------------------------------- /js/node/stream/write_stream.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | 5 | var ws1 = fs.createWriteStream('output1.txt', 'utf-8'); 6 | ws1.write('使用Stream写入文本数据...\n'); 7 | ws1.write('END.'); 8 | ws1.end(); 9 | 10 | var ws2 = fs.createWriteStream('output2.txt'); 11 | ws2.write(new Buffer('使用Stream写入二进制数据...\n', 'utf-8')); 12 | ws2.write(new Buffer('END.', 'utf-8')); 13 | ws2.end(); 14 | 15 | console.log('done.'); 16 | -------------------------------------------------------------------------------- /js/node/timers/timers.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | console.log('Now: ' + new Date().toTimeString()); 4 | 5 | setTimeout(function () { 6 | console.log('Run at ' + new Date().toTimeString()); 7 | }, 1500); 8 | 9 | setInterval(function () { 10 | console.log('Schedule at ' + new Date().toTimeString()); 11 | }, 3000); 12 | 13 | console.log('timer setted.'); 14 | -------------------------------------------------------------------------------- /js/node/tutor/1_new/server.js: -------------------------------------------------------------------------------- 1 | /* 2 | node server.js 3 | */ 4 | 5 | const http = require('node:http'); 6 | const hostname = '127.0.0.1'; 7 | const port = 3000; 8 | const server = http.createServer((req, res) => { 9 | res.statusCode = 200; 10 | res.setHeader('Content-Type', 'text/plain'); 11 | res.end('Hello World\n'); 12 | }); 13 | server.listen(port, hostname, () => { 14 | console.log(`Server running at http://${hostname}:${port}/`); 15 | }); -------------------------------------------------------------------------------- /js/node/web/db/hello-sequelize/config.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | database: "test", 3 | username: "www", 4 | password: "www", 5 | host: "127.0.0.1", 6 | port: 3306, 7 | }; 8 | 9 | module.exports = config; 10 | -------------------------------------------------------------------------------- /js/node/web/db/model-sequelize/config-default.js: -------------------------------------------------------------------------------- 1 | 2 | var config = { 3 | dialect: 'mysql', 4 | database: 'nodejs', 5 | username: 'www', 6 | password: 'www', 7 | host: 'localhost', 8 | port: 3306 9 | }; 10 | 11 | module.exports = config; 12 | -------------------------------------------------------------------------------- /js/node/web/db/model-sequelize/config-test.js: -------------------------------------------------------------------------------- 1 | 2 | var config = { 3 | dialect: 'mysql', 4 | database: 'test', 5 | username: 'www', 6 | password: 'www', 7 | host: 'localhost', 8 | port: 3306 9 | }; 10 | 11 | module.exports = config; 12 | -------------------------------------------------------------------------------- /js/node/web/db/model-sequelize/init-db.js: -------------------------------------------------------------------------------- 1 | // require('babel-core/register')({ 2 | // presets: ['stage-3'] 3 | // }); 4 | 5 | const model = require("./model.js"); 6 | try { 7 | model.sync(); 8 | 9 | console.log("init db ok."); 10 | process.exit(0); 11 | } catch (e) { 12 | console.log(e); 13 | } 14 | -------------------------------------------------------------------------------- /js/node/web/db/model-sequelize/init.sql: -------------------------------------------------------------------------------- 1 | create database nodejs; 2 | 3 | grant all privileges on nodejs.* to 'www'@'%'; 4 | grant all privileges on test.* to 'www'@'%'; 5 | -------------------------------------------------------------------------------- /js/node/web/db/model-sequelize/model.js: -------------------------------------------------------------------------------- 1 | // scan all models defined in models: 2 | const fs = require('fs'); 3 | const db = require('./db'); 4 | 5 | let files = fs.readdirSync(__dirname + '/models'); 6 | 7 | let js_files = files.filter((f)=>{ 8 | return f.endsWith('.js'); 9 | }, files); 10 | 11 | module.exports = {}; 12 | 13 | for (let f of js_files) { 14 | console.log(`import model from file ${f}...`); 15 | let name = f.substring(0, f.length - 3); 16 | module.exports[name] = require(__dirname + '/models/' + f); 17 | } 18 | 19 | module.exports.sync = () => { 20 | db.sync(); 21 | }; 22 | -------------------------------------------------------------------------------- /js/node/web/db/model-sequelize/models/Pet.js: -------------------------------------------------------------------------------- 1 | const db = require('../db'); 2 | 3 | module.exports = db.defineModel('pets', { 4 | ownerId: db.ID, 5 | name: db.STRING(100), 6 | gender: db.BOOLEAN, 7 | birth: db.STRING(10), 8 | }); 9 | -------------------------------------------------------------------------------- /js/node/web/db/model-sequelize/models/User.js: -------------------------------------------------------------------------------- 1 | const db = require('../db'); 2 | 3 | module.exports = db.defineModel('users', { 4 | email: { 5 | type: db.STRING(100), 6 | unique: true 7 | }, 8 | passwd: db.STRING(100), 9 | name: db.STRING(100), 10 | gender: db.BOOLEAN 11 | }); 12 | -------------------------------------------------------------------------------- /js/node/web/koa/url2-koa/app.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | 3 | const bodyParser = require('koa-bodyparser'); 4 | 5 | const controller = require('./controller'); 6 | 7 | const app = new Koa(); 8 | 9 | // log request URL: 10 | app.use(async (ctx, next) => { 11 | console.log(`Process ${ctx.request.method} ${ctx.request.url}...`); 12 | await next(); 13 | }); 14 | 15 | // parse request body: 16 | app.use(bodyParser()); 17 | 18 | // add controllers: 19 | app.use(controller()); 20 | 21 | app.listen(3000); 22 | console.log('app started at port 3000...'); 23 | -------------------------------------------------------------------------------- /js/node/web/koa/url2-koa/controllers/hello.js: -------------------------------------------------------------------------------- 1 | var fn_hello = async (ctx, next) => { 2 | var name = ctx.params.name; 3 | ctx.response.body = `

Hello, ${name}!

`; 4 | }; 5 | 6 | module.exports = { 7 | 'GET /hello/:name': fn_hello 8 | }; 9 | -------------------------------------------------------------------------------- /js/node/web/koa/use-nunjucks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "use-nunjucks", 3 | "version": "1.0.0", 4 | "description": "Test nunjucks", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "node app.js" 8 | }, 9 | "keywords": [ 10 | "nunjucks", 11 | "templating" 12 | ], 13 | "author": "Michael Liao", 14 | "license": "Apache-2.0", 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/michaelliao/learn-javascript.git" 18 | }, 19 | "dependencies": { 20 | "nunjucks": "2.4.2" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /js/node/web/koa/view-koa/controllers/index.js: -------------------------------------------------------------------------------- 1 | // index: 2 | 3 | module.exports = { 4 | 'GET /': async (ctx, next) => { 5 | ctx.render('index.html', { 6 | title: 'Welcome' 7 | }); 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /js/node/web/log/winston/app.js: -------------------------------------------------------------------------------- 1 | const logger = require('./logger.js'); 2 | 3 | logger.info('start app...'); 4 | try { 5 | throw new Error('APP ERROR!'); 6 | } catch (e) { 7 | logger.error('error', e); 8 | } 9 | logger.info('app ended.'); 10 | -------------------------------------------------------------------------------- /js/node/web/log/winston/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "logger", 3 | "version": "1.0.0", 4 | "description": "Log example", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "node app.js" 8 | }, 9 | "keywords": [ 10 | "log", 11 | "winston" 12 | ], 13 | "author": "Michael Liao", 14 | "license": "Apache-2.0", 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/michaelliao/learn-javascript.git" 18 | }, 19 | "dependencies": { 20 | "winston": "2.3.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /js/node/web/rest/rest-hello/app.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | 3 | const bodyParser = require('koa-bodyparser'); 4 | 5 | const controller = require('./controller'); 6 | 7 | const app = new Koa(); 8 | 9 | // log request URL: 10 | app.use(async (ctx, next) => { 11 | console.log(`Process ${ctx.request.method} ${ctx.request.url}...`); 12 | await next(); 13 | }); 14 | 15 | // parse request body: 16 | app.use(bodyParser()); 17 | 18 | // add controller: 19 | app.use(controller()); 20 | 21 | app.listen(3000); 22 | console.log('app started at port 3000...'); 23 | -------------------------------------------------------------------------------- /js/node/web/rest/rest-koa/controllers/index.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | 'GET /': async (ctx, next) => { 4 | ctx.render('index.html'); 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /js/node/web/test/async-test/data.txt: -------------------------------------------------------------------------------- 1 | 1 + (2 + 4) * (9 - 2) / 3 -------------------------------------------------------------------------------- /js/node/web/test/async-test/hello.js: -------------------------------------------------------------------------------- 1 | // hello.js 2 | console.log('init hello.js...'); 3 | 4 | const fs = require('mz/fs'); 5 | 6 | // a simple async function: 7 | module.exports = async () => { 8 | let expression = await fs.readFile('./data.txt', 'utf-8'); 9 | let fn = new Function('return ' + expression); 10 | let r = fn(); 11 | console.log(`Calculate: ${expression} = ${r}`); 12 | return r; 13 | }; 14 | -------------------------------------------------------------------------------- /js/node/web/test/hello-test/hello.js: -------------------------------------------------------------------------------- 1 | // hello.js 2 | console.log('init hello.js...'); 3 | 4 | // a simple function: 5 | // > sum(1, 2, 3) 6 | // 6 7 | module.exports = function (...rest) { 8 | var sum = 0; 9 | for (let n of rest) { 10 | sum += n; 11 | } 12 | return sum; 13 | }; 14 | -------------------------------------------------------------------------------- /js/node/web/test/hello-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mocha-test", 3 | "version": "1.0.0", 4 | "description": "Mocha simple test", 5 | "main": "hello.js", 6 | "scripts": { 7 | "test": "mocha" 8 | }, 9 | "keywords": [ 10 | "mocha", 11 | "test" 12 | ], 13 | "author": "Michael Liao", 14 | "license": "Apache-2.0", 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/michaelliao/learn-javascript.git" 18 | }, 19 | "dependencies": {}, 20 | "devDependencies": { 21 | "mocha": "3.0.2" 22 | } 23 | } -------------------------------------------------------------------------------- /js/node/web/test/koa-test/start.js: -------------------------------------------------------------------------------- 1 | const app = require('./app'); 2 | 3 | app.listen(3000); 4 | console.log('app started at port 3000...'); 5 | -------------------------------------------------------------------------------- /js/node/web/vue/mini-excel/saved-docs/README: -------------------------------------------------------------------------------- 1 | # documents will be saved in this dir. 2 | -------------------------------------------------------------------------------- /js/node/web/ws/hello-ws/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-ws", 3 | "version": "1.0.0", 4 | "description": "Hello WebSocket example", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "node app.js" 8 | }, 9 | "keywords": [ 10 | "ws", 11 | "websocket" 12 | ], 13 | "author": "Michael Liao", 14 | "license": "Apache-2.0", 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/michaelliao/learn-javascript.git" 18 | }, 19 | "dependencies": { 20 | "ws": "1.1.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /js/node/web/ws/ws-with-koa/controllers/index.js: -------------------------------------------------------------------------------- 1 | // index: 2 | 3 | module.exports = { 4 | 'GET /': async (ctx, next) => { 5 | let user = ctx.state.user; 6 | if (user) { 7 | ctx.render('room.html', { 8 | user: user 9 | }); 10 | } else { 11 | ctx.response.redirect('/signin'); 12 | } 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /js/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test" 3 | } 4 | -------------------------------------------------------------------------------- /js/underscore/underscore.js: -------------------------------------------------------------------------------- 1 | function testMap() { 2 | var obj = { 3 | name: "bob", 4 | school: "No.1 middle school", 5 | address: "xueyuan road", 6 | }; 7 | // 注意, map 返回的仅仅是 value 的 Array 8 | var upper = _.map(obj, function (value, key) { 9 | return key + ": " + value.toUpperCase(); 10 | }); 11 | console.log(upper); 12 | 13 | upper = _.mapObject(obj, function (value, key) { 14 | return value.toUpperCase(); 15 | }); 16 | console.log(upper); 17 | } 18 | 19 | testMap(); 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "underscore": "^1.13.2" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "leetcode" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["easonsshi "] 6 | readme = "README.md" 7 | 8 | [tool.poetry.dependencies] 9 | python = "^3.10" 10 | easonsi = "^0.0.8" 11 | 12 | [tool.poetry.group.dev.dependencies] 13 | poetry = "^1.8.4" 14 | 15 | [build-system] 16 | requires = ["poetry-core"] 17 | build-backend = "poetry.core.masonry.api" 18 | -------------------------------------------------------------------------------- /python/Python-NOTE.md: -------------------------------------------------------------------------------- 1 | 2 | - 标准库: 3 | - wiki 4 | - [web frameworks](https://wiki.python.org/moin/WebFrameworks) 5 | 6 | book 7 | 8 | - 《Python基础教程》 9 | - code: 10 | -------------------------------------------------------------------------------- /python/Python-misc/hello.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | print("Hello world!") 4 | a = math.pi; 5 | print(f"The Pi is {a:.10f}") -------------------------------------------------------------------------------- /python/Python-misc/python-ast.py: -------------------------------------------------------------------------------- 1 | import ast 2 | 3 | s = open("./hello.py").read() 4 | print( 5 | ast.dump(ast.parse(s), indent=4) 6 | ) -------------------------------------------------------------------------------- /python/YJR-PythonPJ/_re.py: -------------------------------------------------------------------------------- 1 | 2 | #%% 3 | import re 4 | pat = r"([^,、.有\s]+?)大学" 5 | text = "参加的大学生来自复旦大学、清华大学、中国科技大学还有北京大学等多所大学。" 6 | t = re.findall(pat, text) 7 | print(t[1]) 8 | 9 | # %% 10 | t 11 | # %% 12 | -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/9781484200292.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/beginning-python-3ed-master/9781484200292.jpg -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter02/listing2-2.py: -------------------------------------------------------------------------------- 1 | # Split up a URL of the form http://www.something.com 2 | 3 | url = input('Please enter the URL:') 4 | domain = url[11:-4] 5 | 6 | print("Domain name: " + domain) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter02/listing2-4.py: -------------------------------------------------------------------------------- 1 | # Check a user name and PIN code 2 | 3 | database = [ 4 | ['albert', '1234'], 5 | ['dilbert', '4242'], 6 | ['smith', '7524'], 7 | ['jones', '9843'] 8 | ] 9 | 10 | username = input('User name: ') 11 | pin = input('PIN code: ') 12 | 13 | if [username, pin] in database: print('Access granted') -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-1.py: -------------------------------------------------------------------------------- 1 | # hello.py 2 | print("Hello, world!") -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-10.py: -------------------------------------------------------------------------------- 1 | # find_sender.py 2 | import fileinput, re 3 | pat = re.compile('From: (.*) <.*?>$') 4 | for line in fileinput.input(): 5 | m = pat.match(line) 6 | if m: print(m.group(1)) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-12.txt: -------------------------------------------------------------------------------- 1 | [x = 2] 2 | [y = 3] 3 | The sum of [x] and [y] is [x + y]. -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-13.txt: -------------------------------------------------------------------------------- 1 | [name = 'Magnus Lie Hetland' ] 2 | [email = 'magnus@foo.bar' ] 3 | [language = 'python' ] -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-14.txt: -------------------------------------------------------------------------------- 1 | [import time] 2 | Dear [name], 3 | 4 | I would like to learn how to program. I hear you use 5 | the [language] language a lot -- is it something I 6 | should consider? 7 | 8 | And, by the way, is [email] your correct email address? 9 | 10 | 11 | Fooville, [time.asctime()] 12 | 13 | Oscar Frozzbozz -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-2.py: -------------------------------------------------------------------------------- 1 | # hello2.py 2 | def hello(): 3 | print("Hello, world!") -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-3.py: -------------------------------------------------------------------------------- 1 | # hello3.py 2 | 3 | def hello(): 4 | print("Hello, world!") 5 | 6 | # A test: 7 | hello() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-4.py: -------------------------------------------------------------------------------- 1 | # hello4.py 2 | def hello(): 3 | print("Hello, world!") 4 | 5 | def test(): 6 | hello() 7 | 8 | if __name__ == '__main__': test() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-5.py: -------------------------------------------------------------------------------- 1 | # reverseargs.py 2 | import sys 3 | args = sys.argv[1:] 4 | args.reverse() 5 | print(' '.join(args)) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter10/listing10-6.py: -------------------------------------------------------------------------------- 1 | # numberlines.py 2 | 3 | import fileinput 4 | 5 | for line in fileinput.input(inplace=True): 6 | line = line.rstrip() 7 | num = fileinput.lineno() 8 | print('{:<50} # {:2d}'.format(line, num)) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-1.py: -------------------------------------------------------------------------------- 1 | # somescript.py 2 | import sys 3 | text = sys.stdin.read() 4 | words = text.split() 5 | wordcount = len(words) 6 | print('Wordcount:', wordcount) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-10.py: -------------------------------------------------------------------------------- 1 | with open(filename) as f: 2 | for line in f.readlines(): 3 | process(line) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-11.py: -------------------------------------------------------------------------------- 1 | import fileinput 2 | for line in fileinput.input(filename): 3 | process(line) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-12.py: -------------------------------------------------------------------------------- 1 | with open(filename) as f: 2 | for line in f: 3 | process(line) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-13.py: -------------------------------------------------------------------------------- 1 | for line in open(filename): 2 | process(line) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-2.txt: -------------------------------------------------------------------------------- 1 | Your mother was a hamster and your 2 | father smelled of elderberries. -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-3.txt: -------------------------------------------------------------------------------- 1 | Welcome to this file 2 | There is nothing here except 3 | This stupid haiku -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-4.txt: -------------------------------------------------------------------------------- 1 | this 2 | is no 3 | haiku -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-5.txt: -------------------------------------------------------------------------------- 1 | this 2 | isn't a 3 | haiku -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-6.py: -------------------------------------------------------------------------------- 1 | with open(filename) as f: 2 | char = f.read(1) 3 | while char: 4 | process(char) 5 | char = f.read(1) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-7.py: -------------------------------------------------------------------------------- 1 | with open(filename) as f: 2 | while True: 3 | char = f.read(1) 4 | if not char: break 5 | process(char) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-8.py: -------------------------------------------------------------------------------- 1 | with open(filename) as f: 2 | while True: 3 | line = f.readline() 4 | if not line: break 5 | process(line) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter11/listing11-9.py: -------------------------------------------------------------------------------- 1 | with open(filename) as f: 2 | for char in f.read(): 3 | process(char) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter13/listing13-2.py: -------------------------------------------------------------------------------- 1 | import sqlite3, sys 2 | 3 | conn = sqlite3.connect('food.db') 4 | curs = conn.cursor() 5 | 6 | query = 'SELECT * FROM food WHERE ' + sys.argv[1] 7 | print(query) 8 | curs.execute(query) 9 | names = [f[0] for f in curs.description] 10 | for row in curs.fetchall(): 11 | for pair in zip(names, row): 12 | print('{}: {}'.format(*pair)) 13 | print() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter14/listing14-1.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | s = socket.socket() 4 | 5 | host = socket.gethostname() 6 | port = 1234 7 | s.bind((host, port)) 8 | 9 | s.listen(5) 10 | while True: 11 | c, addr = s.accept() 12 | print('Got connection from', addr 13 | c.send('Thank you for connecting') 14 | c.close() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter14/listing14-2.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | s = socket.socket() 4 | 5 | host = socket.gethostname() 6 | port = 1234 7 | 8 | s.connect((host, port)) 9 | print(s.recv(1024)) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter14/listing14-3.py: -------------------------------------------------------------------------------- 1 | from socketserver import TCPServer, StreamRequestHandler 2 | 3 | class Handler(StreamRequestHandler): 4 | 5 | def handle(self): 6 | addr = self.request.getpeername() 7 | print('Got connection from', addr) 8 | self.wfile.write('Thank you for connecting') 9 | 10 | server = TCPServer(('', 1234), Handler) 11 | server.serve_forever() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter14/listing14-4.py: -------------------------------------------------------------------------------- 1 | from socketserver import TCPServer, ForkingMixIn, StreamRequestHandler 2 | 3 | class Server(ForkingMixIn, TCPServer): pass 4 | 5 | class Handler(StreamRequestHandler): 6 | 7 | def handle(self): 8 | addr = self.request.getpeername() 9 | print('Got connection from', addr) 10 | self.wfile.write('Thank you for connecting') 11 | 12 | server = Server(('', 1234), Handler) 13 | server.serve_forever() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter14/listing14-5.py: -------------------------------------------------------------------------------- 1 | from socketserver import TCPServer, ThreadingMixIn, StreamRequestHandler 2 | 3 | class Server(ThreadingMixIn, TCPServer): pass 4 | 5 | class Handler(StreamRequestHandler): 6 | 7 | def handle(self): 8 | addr = self.request.getpeername() 9 | print('Got connection from', addr) 10 | self.wfile.write('Thank you for connecting') 11 | 12 | server = Server(('', 1234), Handler) 13 | server.serve_forever() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter14/listing14-8.py: -------------------------------------------------------------------------------- 1 | from twisted.internet import reactor 2 | from twisted.internet.protocol import Protocol, Factory 3 | 4 | class SimpleLogger(Protocol): 5 | 6 | def connectionMade(self): 7 | print 'Got connection from', self.transport.client 8 | 9 | def connectionLost(self, reason): 10 | print self.transport.client, 'disconnected' 11 | 12 | def dataReceived(self, data): 13 | print data 14 | 15 | factory = Factory() 16 | factory.protocol = SimpleLogger 17 | 18 | reactor.listenTCP(1234, factory) 19 | reactor.run() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter15/listing15-1.py: -------------------------------------------------------------------------------- 1 | from urllib.request import urlopen 2 | import re 3 | p = re.compile('(.*?)') 4 | text = urlopen('http://python.org/jobs').read().decode() 5 | for url, name in p.findall(text): 6 | print('{} ({})'.format(name, url)) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter15/listing15-3.py: -------------------------------------------------------------------------------- 1 | from urllib.request import urlopen 2 | from bs4 import BeautifulSoup 3 | 4 | text = urlopen('http://python.org/jobs').read() 5 | soup = BeautifulSoup(text, 'html.parser') 6 | 7 | jobs = set() 8 | for job in soup.body.section('h2'): 9 | jobs.add('{} ({})'.format(job.a.string, job.a['href'])) 10 | 11 | print('\n'.join(sorted(jobs, key=str.lower))) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter15/listing15-4.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | print('Content-type: text/plain') 4 | print() # Prints an empty line, to end the headers 5 | 6 | print('Hello, world!') -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter15/listing15-5.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import cgitb; cgitb.enable() 4 | 5 | print('Content-type: text/html\n') 6 | 7 | print(1/0) 8 | 9 | print('Hello, world!') -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter15/listing15-6.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import cgi 4 | form = cgi.FieldStorage() 5 | 6 | name = form.getvalue('name', 'world') 7 | 8 | print('Content-type: text/plain\n') 9 | 10 | print('Hello, {}!'.format(name)) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter15/listing15-7.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import cgi 4 | form = cgi.FieldStorage() 5 | 6 | name = form.getvalue('name', 'world') 7 | 8 | print("""Content-type: text/html 9 | 10 | 11 | 12 | Greeting Page 13 | 14 | 15 |

Hello, %s!

16 | 17 | 18 |
19 | Change name 20 | 21 |
22 | 23 | 24 | """.format(name)) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter16/listing16-1.py: -------------------------------------------------------------------------------- 1 | from area import rect_area 2 | height = 3 3 | width = 4 4 | correct_answer = 12 5 | answer = rect_area(height, width) 6 | if answer == correct_answer: 7 | print('Test passed ') 8 | else: 9 | print('Test failed ') -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter17/listing17-1.java: -------------------------------------------------------------------------------- 1 | public class JythonTest { 2 | 3 | public void greeting() { 4 | System.out.println("Hello, world!"); 5 | } 6 | 7 | } -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter17/listing17-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace FePyTest { 3 | public class IronPythonTest { 4 | 5 | public void greeting() { 6 | Console.WriteLine("Hello, world!"); 7 | } 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter17/listing17-3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int is_palindrome(char *text) { 4 | int i, n = strlen(text); 5 | for (i = 0; i <= n/2; ++i) { 6 | if (text[i] != text[n-i-1]) return 0; 7 | } 8 | return 1; 9 | } -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter17/listing17-4.py: -------------------------------------------------------------------------------- 1 | def is_palindrome(text): 2 | n = len(text) 3 | for i in range(len(text)//2): 4 | if text[i] != text[n-i-1]: 5 | return False 6 | return True -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter17/listing17-5.i: -------------------------------------------------------------------------------- 1 | %module palindrome 2 | 3 | %{ 4 | #include 5 | %} 6 | 7 | extern int is_palindrome(char *text); -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter18/listing18-1.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='Hello', 4 | version='1.0', 5 | description='A simple example', 6 | author='Magnus Lie Hetland', 7 | py_modules=['hello']) -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter19/listing19-1.cfg: -------------------------------------------------------------------------------- 1 | [numbers] 2 | 3 | pi: 3.1415926535897931 4 | 5 | [messages] 6 | 7 | greeting: Welcome to the area calculation program! 8 | question: Please enter the radius: 9 | result_message: The area is -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter19/listing19-3.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logging.basicConfig(level=logging.INFO, filename='mylog.log') 4 | 5 | logging.info('Starting program') 6 | 7 | logging.info('Trying to divide 1 by 0') 8 | 9 | print(1 / 0) 10 | 11 | logging.info('The division succeeded') 12 | 13 | logging.info('Ending program') -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter20/listing20-2.py: -------------------------------------------------------------------------------- 1 | def lines(file): 2 | for line in file: yield line 3 | yield '\n' 4 | 5 | def blocks(file): 6 | block = [] 7 | for line in lines(file): 8 | if line.strip(): 9 | block.append(line) 10 | elif block: 11 | yield ''.join(block).strip() 12 | block = [] -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter20/listing20-3.py: -------------------------------------------------------------------------------- 1 | import sys, re 2 | from util import * 3 | 4 | print('...') 5 | 6 | title = True 7 | for block in blocks(sys.stdin): 8 | block = re.sub(r'\*(.+?)\*', r'\1', block) 9 | if title: 10 | print('

') 11 | print(block) 12 | print('

') 13 | title = False 14 | else: 15 | print('

') 16 | print(block) 17 | print('

') 18 | 19 | print('') -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter21/listing21-1.py: -------------------------------------------------------------------------------- 1 | from reportlab.graphics.shapes import Drawing, String 2 | from reportlab.graphics import renderPDF 3 | 4 | d = Drawing(100, 100) 5 | s = String(50, 50, 'Hello, world!', textAnchor='middle') 6 | 7 | d.add(s) 8 | 9 | renderPDF.drawToFile(d, 'hello.pdf', 'A simple PDF file') -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter24/listing24-1.py: -------------------------------------------------------------------------------- 1 | from asyncore import dispatcher 2 | import asyncore 3 | 4 | class ChatServer(dispatcher): pass 5 | 6 | s = ChatServer() 7 | asyncore.loop() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter24/listing24-2.py: -------------------------------------------------------------------------------- 1 | from asyncore import dispatcher 2 | import socket, asyncore 3 | 4 | class ChatServer(dispatcher): 5 | 6 | def handle_accept(self): 7 | conn, addr = self.accept() 8 | print('Connection attempt from', addr[0]) 9 | 10 | s = ChatServer() 11 | s.create_socket(socket.AF_INET, socket.SOCK_STREAM) 12 | s.bind(('', 5005)) 13 | s.listen(5) 14 | asyncore.loop() -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter26/listing26-1.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE messages ( 2 | id SERIAL PRIMARY KEY, 3 | subject TEXT NOT NULL, 4 | sender TEXT NOT NULL, 5 | reply_to INTEGER REFERENCES messages, 6 | text TEXT NOT NULL 7 | ); -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter26/listing26-2.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE messages ( 2 | id INT NOT NULL AUTO_INCREMENT, 3 | subject VARCHAR(100) NOT NULL, 4 | sender VARCHAR(15) NOT NULL, 5 | reply_to INT, 6 | text MEDIUMTEXT NOT NULL, 7 | PRIMARY KEY(id) 8 | ); -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/Chapter26/listing26-3.sql: -------------------------------------------------------------------------------- 1 | create table messages ( 2 | id integer primary key autoincrement, 3 | subject text not null, 4 | sender text not null, 5 | reply_to int, 6 | text text not null 7 | ); -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/beginning-python-3ed-master/LICENSE.txt -------------------------------------------------------------------------------- /python/beginning-python-3ed-master/README.md: -------------------------------------------------------------------------------- 1 | #Apress Source Code 2 | 3 | This repository accompanies [*Beginning Python*](http://www.apress.com/9781484200292) by Magnus Lie Hetland (Apress, 2017). 4 | 5 | ![Cover image](9781484200292.jpg) 6 | 7 | Download the files as a zip using the green button, or clone the repository to your machine using Git. 8 | 9 | ##Releases 10 | 11 | Release v1.0 corresponds to the code in the published book, without corrections or updates. 12 | 13 | ##Contributions 14 | 15 | See the file Contributing.md for more information on how you can contribute to this repository. 16 | -------------------------------------------------------------------------------- /python/helloworld.py: -------------------------------------------------------------------------------- 1 | """ 2 | from https://code.visualstudio.com/docs/python/debugging 3 | """ 4 | 5 | import matplotlib.pyplot as plt 6 | import numpy as np 7 | 8 | x = np.linspace(0, 20, 100) # Create a list of evenly-spaced numbers over the range 9 | plt.plot(x, np.sin(x)) # Plot the sine of each x point 10 | plt.show() # Display the plot -------------------------------------------------------------------------------- /python/misc/ref.py: -------------------------------------------------------------------------------- 1 | #%% 2 | """ 3 | 变量并不直接存储值,而是存储值的引用。Python调用函数时,实参到形参都是传递的引用。 4 | """ 5 | nums = [1,2] 6 | def swap(arr: list): 7 | arr.reverse() 8 | print(f"nums before: {nums}") 9 | swap(nums) 10 | print(f"nums after: {nums}") 11 | 12 | # %% 13 | -------------------------------------------------------------------------------- /python/notes/media/Python note/16087172700264.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16087172700264.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16087230546557.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16087230546557.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16087234265571.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16087234265571.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16087238216033.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16087238216033.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16087252956536.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16087252956536.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16087276625102.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16087276625102.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16087276753956.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16087276753956.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090356051025.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090356051025.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090379558633.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090379558633.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090386184186.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090386184186.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090387250946.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090387250946.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090389379048.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090389379048.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090762594110.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090762594110.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090762938863.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090762938863.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090777817544.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090777817544.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090780982856.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090780982856.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090793142436.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090793142436.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090797540028.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090797540028.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090798648334.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090798648334.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090824106434.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090824106434.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16090827528574.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16090827528574.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091292039635.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091292039635.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091292718104.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091292718104.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091327029724.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091327029724.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091333143775.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091333143775.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091335952821.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091335952821.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091368085806.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091368085806.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091381782490.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091381782490.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091387408303.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091387408303.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091423869167.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091423869167.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091432750244.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091432750244.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091436732720.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091436732720.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091442591864.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091442591864.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091452147197.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091452147197.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091453853914.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091453853914.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091473928674.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091473928674.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091499702206.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091499702206.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091502617049.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091502617049.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091503717829.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091503717829.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091504628480.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091504628480.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091517544151.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091517544151.jpg -------------------------------------------------------------------------------- /python/notes/media/Python note/16091526454085.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/Python note/16091526454085.jpg -------------------------------------------------------------------------------- /python/notes/media/python-readme/2022-08-03-14-37-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/notes/media/python-readme/2022-08-03-14-37-18.png -------------------------------------------------------------------------------- /python/profile_/line_/line_profiler_2.py.lprof: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/profile_/line_/line_profiler_2.py.lprof -------------------------------------------------------------------------------- /python/profile_/profile_/profile_2.py: -------------------------------------------------------------------------------- 1 | import re 2 | import cProfile 3 | cProfile.run('re.compile("foo|bar")', 'restats') -------------------------------------------------------------------------------- /python/profile_/profile_/pstats_1.py: -------------------------------------------------------------------------------- 1 | import pstats 2 | from pstats import SortKey 3 | p = pstats.Stats('restats') 4 | p.strip_dirs().sort_stats(-1).print_stats() 5 | 6 | p.sort_stats(SortKey.NAME) 7 | p.print_stats() 8 | 9 | p.sort_stats(SortKey.CUMULATIVE).print_stats(10) 10 | 11 | p.print_callees() 12 | p.add('restats') -------------------------------------------------------------------------------- /python/profile_/profile_/restats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightblues/Leetcode/e38516e0b00b93f0e955d0ce1299c39453518fd3/python/profile_/profile_/restats -------------------------------------------------------------------------------- /python/sql/python-sql-NOTE.md: -------------------------------------------------------------------------------- 1 | - API: [PEP 249](https://peps.python.org/pep-0249/) 2 | - 简化操作的库: SQLobject: 3 | -------------------------------------------------------------------------------- /r/basic/14-工作空间和变量赋值.R: -------------------------------------------------------------------------------- 1 | # 变量赋值与绑定 2 | x <- c(1, 2, 3) 3 | cat(tracemem(x), "\n") # <0x7f8e14874d88> 4 | y <- x # 这时y和x绑定到同一R对象 5 | cat(tracemem(y), "\n") # <0x7f8e14874d88> 6 | y[3] <- 0 # 这时y制作了副本 7 | # tracemem[0x7f8e2dd52608 -> 0x7f8e14901ca8]: 8 | 9 | tracemem(x) # <0x7f8e14874d88> 10 | tracemem(y) # <0x7f8e14832cc8> 11 | 12 | # 对于变量重新赋值不会对对象进行复制 13 | y <- c(1, 2) 14 | 15 | untracemem(x) 16 | untracemem(y) 17 | rm(x, y) -------------------------------------------------------------------------------- /r/basic/basic.R: -------------------------------------------------------------------------------- 1 | getwd() 2 | 3 | tax.tab <- read.csv("data/Rbook/taxsamp.csv", 4 | # as.is=TRUE说明字符型列要原样读入而不是转换为因子(factor) 5 | header=TRUE, as.is=TRUE) 6 | print(head(tax.tab)) 7 | -------------------------------------------------------------------------------- /r/learn-r.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | sortedcontainers 2 | -------------------------------------------------------------------------------- /rust/hello_world/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "hello_world" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /rust/hello_world/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_world" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /rust/hello_world/src/main.rs: -------------------------------------------------------------------------------- 1 | fn greet_world() { 2 | let southern_germany = "Grüß Gott!"; 3 | let chinese = "世界,你好"; 4 | let english = "World, hello"; 5 | let regions = [southern_germany, chinese, english]; 6 | // 转为迭代器. 如果不写的话 for会进行隐式转换 7 | for region in regions.iter() { 8 | // ! 是宏操作符 9 | println!("{}", ®ion); 10 | } 11 | } 12 | 13 | fn main() { 14 | greet_world(); 15 | } 16 | -------------------------------------------------------------------------------- /rust/learn-basic/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | 9 | ] 10 | } -------------------------------------------------------------------------------- /rust/learn-basic/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "variables" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | num = "0.4.0" 10 | -------------------------------------------------------------------------------- /rust/learn-basic/src/2-2-fn.rs: -------------------------------------------------------------------------------- 1 | // 所有 identifier 都要指明类型; 返回值默认为 (), 否则需要明确 2 | fn add(a: i32, b: i32) -> i32 { 3 | a + b 4 | } 5 | 6 | fn main(){ 7 | println!("{}", add(1, 2)); 8 | } -------------------------------------------------------------------------------- /rust/learn-basic/src/2-3-borow.rs: -------------------------------------------------------------------------------- 1 | 2 | fn bollow_changable(){ 3 | let mut s = String::from("hello"); 4 | 5 | // 可变引用只能存在一个 6 | let r1 = &mut s; 7 | // let r2 = &mut s; 8 | println!("{}", r1); 9 | println!("{}", r1); 10 | 11 | // 引用的作用域到「最后一次使用的位置」 12 | let r2 = &mut s; 13 | r2.push_str(", world"); 14 | println!("{}", r2); 15 | } 16 | 17 | fn main(){ 18 | bollow_changable(); 19 | } -------------------------------------------------------------------------------- /rust/readme.md: -------------------------------------------------------------------------------- 1 | 2 | ref 3 | 4 | - Rust by Practice: [GitHub](https://github.com/sunface/rust-by-practice) 5 | - Rust算法题解: [GitHub](https://github.com/rustlang-cn/rust-algos) 6 | -------------------------------------------------------------------------------- /shell/101_basic/infos.sh: -------------------------------------------------------------------------------- 1 | # ==================== 监控; 基本信息 2 | # 架构 3 | uname -a 4 | 5 | # CPU 信息 6 | cat /proc/cpuinfo 7 | 8 | # GPU 9 | # https://askubuntu.com/questions/5417/how-to-get-the-gpu-info 10 | sudo lshw -C display # 一般这条就可以 11 | lspci -v -s $(lspci | grep ' VGA ' | cut -d" " -f 1) 12 | 13 | # 查看电源型号/状态 14 | sudo dmidecode --type 39 15 | # 功率监控 16 | sudo powertop -------------------------------------------------------------------------------- /shell/examples/2312_fdu/list_users.sh: -------------------------------------------------------------------------------- 1 | # 列出所有的用户, 筛选用户名中带有 22 的, 输出到 o.txt 中 2 | 3 | #!/bin/bash 4 | 5 | fn=userlist.txt 6 | # 使用 awk 命令来获取所有用户的用户名,并筛选包含 "22", "23", 或 "24" 的用户名 7 | usernames=$(awk -F: '$3 >= 1000 {print $1}' /etc/passwd | grep -E "22|23|24") 8 | echo "$usernames" > $fn 9 | echo "筛选后的用户名已保存到 $fn" 10 | -------------------------------------------------------------------------------- /shell/if.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $USER == easonshi ] 4 | then 5 | echo Hello easonshi! 6 | fi 7 | 8 | case $USER in 9 | rich | barbara) 10 | echo Not allowed!;; 11 | easonshi) 12 | echo Welcome, $USER 13 | echo hello;; 14 | esac -------------------------------------------------------------------------------- /shell/services/mysql.sh: -------------------------------------------------------------------------------- 1 | ########################## SQL 2 | sudo apt update 3 | sudo apt install mysql-server 4 | # 验证安装成功 5 | mysqladmin --version 6 | # 创建用户(默认直接 mysql 登陆无密码) 7 | mysqladmin -u root password 123456 8 | # 登陆 9 | mysql -uroot -p 10 | -------------------------------------------------------------------------------- /stat/tt.py: -------------------------------------------------------------------------------- 1 | raw = "{'coulmn_type': 'natural language text', 'reason': 'The 'address' column contains ...'}" 2 | def eval_result(text:str): 3 | try: 4 | return eval(text) 5 | except: 6 | ratextw = text.strip(" {}") 7 | parts = ratextw.split("', '") 8 | res = {} 9 | for part in parts: 10 | key, value = part.split(": '") 11 | res[key.strip("'")] = value.strip("'") 12 | return res 13 | 14 | print(eval_result(raw)) --------------------------------------------------------------------------------