├── .nojekyll ├── 02~数据结构 ├── 线性表 │ ├── 列表.md │ ├── 集合.md │ ├── SkipList.md │ └── 链表 │ │ └── README.md ├── 压缩 │ └── zlib │ │ ├── gzip.md │ │ └── README.md ├── 数组 │ ├── README.md │ ├── 矩阵 │ │ └── README.md │ ├── .DS_Store │ ├── 滑动窗口 │ │ ├── README.md │ │ └── 滑动窗口均值 │ │ │ ├── go.mod │ │ │ ├── README.md │ │ │ └── main_test.go │ └── 数列 │ │ └── 斐波那契数列.md ├── 字符串 │ ├── 模式匹配 │ │ ├── 单模式匹配 │ │ │ ├── BM.md │ │ │ ├── Sunday.md │ │ │ └── README.md │ │ └── 多模式匹配.md │ ├── Base64 │ │ └── README.md │ ├── JSON │ │ └── 99~参考资料 │ │ │ └── 2023~Building a high performance JSON parser.md │ ├── Trie │ │ └── README.md │ └── 正则表达式 │ │ └── 01.结构与操作符.md ├── 树 │ ├── 多叉树 │ │ ├── README.md │ │ └── 二叉树.md │ └── 哈夫曼 │ │ └── README.md ├── 简单数论 │ ├── 大数操作.md │ ├── 数组序列.md │ ├── 矩阵乘法.md │ ├── 科学计算.md │ └── 位运算.md ├── .DS_Store ├── 栈与队列 │ ├── .DS_Store │ ├── 时间轮 │ │ └── README.md │ ├── LRU.md │ └── 多级反馈队列.md ├── 哈希表 │ └── 过滤器 │ │ ├── CuckooFilter.md │ │ └── SuRF.md ├── README.md └── 时间日期 │ └── 时区.md ├── 03~排序 ├── 分配排序 │ ├── README.md │ └── 基数排序.md ├── 树形排序 │ ├── README.md │ └── 桶排序.md ├── 分治排序 │ └── README.md ├── .DS_Store ├── REAMDE.md ├── 99~参考资料 │ └── 2018~《十大经典排序算法》 │ │ ├── .travis.yml │ │ ├── src │ │ └── java │ │ │ └── main │ │ │ ├── IArraySort.java │ │ │ ├── InsertSort.java │ │ │ ├── ShellSort.java │ │ │ ├── BubbleSort.java │ │ │ └── SelectionSort.java │ │ ├── SUMMARY.md │ │ ├── .gitignore │ │ └── .github │ │ └── FUNDING.yml ├── 外部排序 │ └── README.md └── 简单排序 │ ├── insert_sort.go │ ├── 选择排序.md │ └── README.md ├── 03~博弈论 └── README.md ├── INTRODUCTION.md ├── 03~图论 ├── 最短路径 │ ├── SPFA.md │ ├── 全源最短路径.md │ └── 多段图中的最短路径.md ├── .DS_Store ├── README.md └── 图遍历 │ └── README.md ├── 03~查找与搜索 ├── 搜索回溯 │ └── README.md ├── .DS_Store ├── 查找树 │ ├── Trie │ │ └── README.md │ └── 红黑树 │ │ └── README.md └── 二分查找 │ └── 二分查找.md ├── 10~LeetCode ├── README.md └── 99~参考资料 │ └── 2024~LeetCode Questions CompanyWise │ ├── emc_2year.csv │ ├── emc_alltime.csv │ ├── fallible_alltime.csv │ ├── inmobi_alltime.csv │ ├── radius_2year.csv │ ├── valve_2year.csv │ ├── fidessa_alltime.csv │ ├── ge-digital_2year.csv │ ├── groupon_6months.csv │ ├── hotstar_alltime.csv │ ├── limebike_alltime.csv │ ├── samsung_6months.csv │ ├── zscaler_alltime.csv │ ├── arista_alltime.csv │ ├── booking_alltime.csv │ ├── bytedancetoutiao_alltime.csv │ ├── pramp_alltime.csv │ ├── works-applications_2year.csv │ ├── zappos_1year.csv │ ├── zappos_2year.csv │ ├── dell_1year.csv │ ├── f5-networks_alltime.csv │ ├── gilt-groupe_alltime.csv │ ├── godaddy_6months.csv │ ├── helix_alltime.csv │ ├── quantcast_2year.csv │ ├── dataminr_1year.csv │ ├── quantcast_alltime.csv │ ├── rackspace_alltime.csv │ ├── airtel_alltime.csv │ ├── blizzard_2year.csv │ ├── blizzard_alltime.csv │ ├── ibm_6months.csv │ ├── jump-trading_2year.csv │ ├── jump-trading_alltime.csv │ ├── mckinsey_alltime.csv │ ├── poynt_alltime.csv │ ├── sapient_alltime.csv │ ├── wayfair_6months.csv │ ├── zalando_alltime.csv │ ├── affinity_alltime.csv │ ├── flexport_alltime.csv │ ├── grab_1year.csv │ ├── iit-bombay_alltime.csv │ ├── jingchi_alltime.csv │ ├── snapdeal_alltime.csv │ ├── thumbtack_alltime.csv │ ├── twitch_6months.csv │ ├── yatra_alltime.csv │ ├── electronic-arts_1year.csv │ ├── huawei_6months.csv │ ├── national-instruments_alltime.csv │ ├── palantir_alltime.csv │ ├── riot-games_6months.csv │ ├── akamai_alltime.csv │ ├── clutter_alltime.csv │ ├── factset_6months.csv │ ├── machinezone_alltime.csv │ ├── jane-street_alltime.csv │ ├── leap-motion_alltime.csv │ ├── phonepe_alltime.csv │ ├── traveloka_alltime.csv │ ├── druva_alltime.csv │ ├── meituan_2year.csv │ ├── paytm_alltime.csv │ ├── pocket-gems_6months.csv │ ├── accolite_alltime.csv │ ├── akuna_alltime.csv │ ├── jp-morgan-chase_alltime.csv │ ├── maq-software_alltime.csv │ ├── meituan_alltime.csv │ ├── microstrategy_alltime.csv │ ├── opendoor_1year.csv │ ├── qualcomm_6months.csv │ ├── symantec_2year.csv │ ├── symantec_alltime.csv │ ├── tandemg_alltime.csv │ ├── forusall_2year.csv │ ├── kakao_alltime.csv │ ├── walmart_alltime.csv │ ├── zillow_6months.csv │ ├── codenation_alltime.csv │ ├── deliveryhero_alltime.csv │ ├── alation_1year.csv │ ├── alation_2year.csv │ ├── alation_alltime.csv │ ├── bloomreach_alltime.csv │ ├── valve_alltime.csv │ ├── radius_alltime.csv │ ├── alibaba_6months.csv │ ├── ge-digital_alltime.csv │ ├── aetion_2year.csv │ ├── honey_alltime.csv │ ├── hulu_6months.csv │ ├── liveramp_1year.csv │ ├── poshmark_alltime.csv │ ├── cloudera_6months.csv │ ├── robinhood_6months.csv │ ├── uipath_alltime.csv │ ├── barclays_1year.csv │ ├── c3-iot_alltime.csv │ ├── epic-systems_1year.csv │ ├── tableau_6months.csv │ ├── garena_2year.csv │ ├── machine-zone_alltime.csv │ ├── riot-games_1year.csv │ ├── turvo_alltime.csv │ ├── cohesity_1year.csv │ ├── zappos_alltime.csv │ ├── splunk_6months.csv │ ├── airbnb_6months.csv │ ├── arista-networks_1year.csv │ ├── coursera_6months.csv │ ├── infosys_alltime.csv │ ├── c3ai_alltime.csv │ ├── medianet_alltime.csv │ ├── reddit_6months.csv │ ├── triplebyte_1year.csv │ ├── netsuite_alltime.csv │ ├── triplebyte_6months.csv │ ├── cruise-automation_6months.csv │ ├── united-health-group_alltime.csv │ ├── akuna-capital_6months.csv │ ├── groupon_1year.csv │ ├── appdynamics_6months.csv │ ├── redfin_1year.csv │ ├── alibaba_1year.csv │ ├── aetion_alltime.csv │ ├── affirm_6months.csv │ ├── dell_2year.csv │ ├── dell_alltime.csv │ ├── nvidia_6months.csv │ ├── postmates_6months.csv │ ├── dataminr_2year.csv │ ├── evernote_1year.csv │ ├── forusall_alltime.csv │ ├── garena_alltime.csv │ ├── jpmorgan_6months.csv │ ├── riot-games_2year.csv │ ├── dropbox_6months.csv │ ├── pure-storage_1year.csv │ ├── pure-storage_6months.csv │ ├── quip_6months.csv │ ├── blackrock_1year.csv │ ├── coursera_1year.csv │ ├── deutsche-bank_alltime.csv │ ├── opendoor_2year.csv │ ├── opendoor_alltime.csv │ ├── palantir-technologies_6months.csv │ ├── reddit_1year.csv │ ├── tripadvisor_1year.csv │ ├── deutsche-bank_2year.csv │ ├── ponyai_2year.csv │ ├── zoho_1year.csv │ ├── karat_6months.csv │ ├── pinterest_6months.csv │ ├── tencent_6months.csv │ ├── ixl_6months.csv │ ├── appdynamics_1year.csv │ ├── citrix_6months.csv │ ├── coupang_6months.csv │ ├── american-express_alltime.csv │ ├── asana_6months.csv │ ├── hbo_2year.csv │ ├── hbo_alltime.csv │ ├── de-shaw_alltime.csv │ ├── hrt_alltime.csv │ ├── dataminr_alltime.csv │ ├── postmates_1year.csv │ ├── epic-systems_2year.csv │ ├── netease_2year.csv │ ├── riot-games_alltime.csv │ ├── liveramp_2year.csv │ ├── twilio_6months.csv │ ├── zoho_2year.csv │ ├── zulily_1year.csv │ ├── factset_1year.csv │ ├── box_6months.csv │ ├── evernote_2year.csv │ ├── evernote_alltime.csv │ ├── houzz_1year.csv │ ├── two-sigma_6months.csv │ ├── karat_1year.csv │ ├── karat_2year.csv │ ├── karat_alltime.csv │ ├── ponyai_alltime.csv │ ├── works-applications_alltime.csv │ ├── gsn-games_alltime.csv │ ├── visa_6months.csv │ ├── triplebyte_2year.csv │ ├── triplebyte_alltime.csv │ ├── bookingcom_2year.csv │ ├── bookingcom_alltime.csv │ ├── didi_6months.csv │ ├── godaddy_1year.csv │ ├── intel_1year.csv │ ├── virtu_1year.csv │ ├── virtu_2year.csv │ ├── virtu_6months.csv │ ├── virtu_alltime.csv │ ├── sumologic_1year.csv │ ├── flipkart_1year.csv │ ├── netflix_6months.csv │ ├── tableau_1year.csv │ ├── box_1year.csv │ ├── cloudera_1year.csv │ ├── drawbridge_2year.csv │ ├── point72_alltime.csv │ ├── twitch_1year.csv │ ├── arista-networks_2year.csv │ ├── arista-networks_alltime.csv │ ├── robinhood_1year.csv │ ├── factset_2year.csv │ ├── zoho_alltime.csv │ ├── electronic-arts_2year.csv │ ├── electronic-arts_alltime.csv │ ├── yelp_1year.csv │ ├── sap_6months.csv │ ├── ibm_1year.csv │ ├── morgan-stanley_1year.csv │ ├── qualtrics_6months.csv │ ├── epic-systems_alltime.csv │ ├── affirm_1year.csv │ ├── netease_alltime.csv │ ├── reddit_2year.csv │ ├── reddit_alltime.csv │ ├── intuit_6months.csv │ ├── wish_6months.csv │ ├── pocket-gems_1year.csv │ ├── nutanix_6months.csv │ ├── barclays_2year.csv │ ├── barclays_alltime.csv │ ├── hulu_1year.csv │ ├── asana_1year.csv │ ├── asana_2year.csv │ ├── blackrock_2year.csv │ ├── blackrock_alltime.csv │ ├── asana_alltime.csv │ ├── audible_6months.csv │ ├── cloudera_2year.csv │ ├── coupang_1year.csv │ ├── drawbridge_alltime.csv │ ├── rubrik_2year.csv │ ├── docusign_6months.csv │ ├── netflix_1year.csv │ ├── samsung_1year.csv │ ├── square_6months.csv │ ├── twilio_1year.csv │ ├── coupang_2year.csv │ ├── qualcomm_1year.csv │ ├── appdynamics_2year.csv │ ├── factset_alltime.csv │ ├── box_alltime.csv │ ├── box_2year.csv │ └── pocket-gems_2year.csv ├── 99~参考资料 ├── 《剑指 Offer》 │ └── README.md ├── 《程序员编程技艺》 │ ├── code │ │ ├── cpp │ │ │ ├── 3.1:二分查找实现(Jon Bentley │ │ │ ├── makefile │ │ │ └── chapter04.cpp │ │ ├── java │ │ │ ├── chapter3 │ │ │ │ ├── IFindMinK.java │ │ │ │ ├── HeapSolution.java │ │ │ │ └── Chapter3.java │ │ │ └── chapter2 │ │ │ │ ├── ICompare.java │ │ │ │ ├── HashTableCompare.java │ │ │ │ └── SortAndCompare.java │ │ ├── ruby │ │ │ ├── chapter19.rb │ │ │ ├── chapter17.rb │ │ │ ├── chapter03.rb │ │ │ ├── chapter06.amicableNumber.rb │ │ │ ├── chapter18.rb │ │ │ ├── chapter16.permutation.rb │ │ │ └── chapter07.findMaxSum.rb │ │ ├── python │ │ │ ├── 6.5:全排列.py │ │ │ ├── 2.3:求解500万以内的亲和数_2.py │ │ │ ├── 3.1:二分查找实现.py │ │ │ ├── 6.6:跳台阶.py │ │ │ ├── 6.8:第一个只出现一次等问题.py │ │ │ ├── 2.1:寻找最小的k个数_2.py │ │ │ ├── 3.3:出现次数超过一半的数字.py │ │ │ ├── 2.4:寻找和为定值的两个数.py │ │ │ ├── 2.6:求连续子数组的最大和.py │ │ │ └── chapter04.py │ │ ├── c │ │ │ ├── 6.6:跳台阶问题.c │ │ │ ├── makefile │ │ │ ├── 2.8:矩阵相乘之Strassen算法.c │ │ │ ├── 5.4:交替字符串.c │ │ │ ├── 2.7:荷兰国旗问题.c │ │ │ ├── 4.3:出现次数超过一半的数字.c │ │ │ ├── 3.2:杨氏矩阵查找.c │ │ │ ├── 2.4:寻找和为定值的两个数.c │ │ │ ├── 7.2:最短摘要的生成.c │ │ │ └── 3.1:二分查找实现.c │ │ ├── scheme │ │ │ ├── chapter01.scm │ │ │ ├── chapter25.scm │ │ │ └── chapter06.scm │ │ ├── js │ │ │ ├── 1.1:左旋转字符串 │ │ │ │ ├── test.html │ │ │ │ └── tests.js │ │ │ ├── 1.2:字符串是否包含问题 │ │ │ │ └── test.html │ │ │ └── 2.4:寻找和为定值的两个数 │ │ │ │ └── test.html │ │ ├── erlang │ │ │ └── 1.1:左旋转字符串.erl │ │ └── go │ │ │ └── 3.2-杨氏矩阵查找.go │ ├── 08~附录 │ │ ├── 08.05.md │ │ └── 08.00.md │ ├── 06~海量数据处理 │ │ ├── 06.10.md │ │ ├── 06.06.md │ │ ├── 06.00.md │ │ └── 06.11.md │ ├── 04~查找匹配 │ │ └── .DS_Store │ ├── 01~字符串 │ │ └── 01.00.md │ ├── 05~动态规划 │ │ └── 05.00.md │ ├── 02~数组 │ │ └── 02.00.md │ └── 03~树 │ │ └── 03.00.md ├── .DS_Store └── 王道~《数据结构》 │ ├── 数据结构.pdf │ └── 数据结构知识框架.xmind ├── 03~动态规划 └── 背包问题.md ├── .DS_Store ├── 01~算法基础 ├── .DS_Store ├── README.md └── 算法思维 │ ├── 递推法.md │ ├── 枚举法.md │ ├── 回溯法.md │ ├── 贪心法.md │ ├── 迭代法.md │ └── 分支限界法.md └── .gitattributes /.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /02~数据结构/线性表/列表.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /02~数据结构/压缩/zlib/gzip.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /02~数据结构/数组/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /03~排序/分配排序/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /03~排序/树形排序/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /02~数据结构/字符串/模式匹配/单模式匹配/BM.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /03~博弈论/README.md: -------------------------------------------------------------------------------- 1 | # 博弈论 2 | -------------------------------------------------------------------------------- /INTRODUCTION.md: -------------------------------------------------------------------------------- 1 | # 本篇导读 2 | -------------------------------------------------------------------------------- /02~数据结构/字符串/模式匹配/单模式匹配/Sunday.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /02~数据结构/树/多叉树/README.md: -------------------------------------------------------------------------------- 1 | # 二叉树 2 | -------------------------------------------------------------------------------- /02~数据结构/树/多叉树/二叉树.md: -------------------------------------------------------------------------------- 1 | # 二叉树 2 | -------------------------------------------------------------------------------- /02~数据结构/简单数论/大数操作.md: -------------------------------------------------------------------------------- 1 | # 大数操作 2 | -------------------------------------------------------------------------------- /02~数据结构/简单数论/数组序列.md: -------------------------------------------------------------------------------- 1 | # 数组序列 2 | -------------------------------------------------------------------------------- /02~数据结构/简单数论/矩阵乘法.md: -------------------------------------------------------------------------------- 1 | # 矩阵乘法 2 | -------------------------------------------------------------------------------- /03~图论/最短路径/SPFA.md: -------------------------------------------------------------------------------- 1 | # SPFA 2 | -------------------------------------------------------------------------------- /03~图论/最短路径/全源最短路径.md: -------------------------------------------------------------------------------- 1 | # 全源最短路径 2 | -------------------------------------------------------------------------------- /02~数据结构/数组/矩阵/README.md: -------------------------------------------------------------------------------- 1 | # 矩阵运算 2 | -------------------------------------------------------------------------------- /03~查找与搜索/搜索回溯/README.md: -------------------------------------------------------------------------------- 1 | # 搜索回溯 2 | -------------------------------------------------------------------------------- /10~LeetCode/README.md: -------------------------------------------------------------------------------- 1 | # LeetCode 2 | -------------------------------------------------------------------------------- /99~参考资料/《剑指 Offer》/README.md: -------------------------------------------------------------------------------- 1 | # 剑指 Offer 2 | -------------------------------------------------------------------------------- /03~动态规划/背包问题.md: -------------------------------------------------------------------------------- 1 | # 背包问题 2 | 3 | # 0-1 背包 4 | -------------------------------------------------------------------------------- /03~排序/分治排序/README.md: -------------------------------------------------------------------------------- 1 | # 分治排序 | Divide and Conquer 2 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/cpp/3.1:二分查找实现(Jon Bentley: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /02~数据结构/字符串/模式匹配/单模式匹配/README.md: -------------------------------------------------------------------------------- 1 | # 模式匹配 2 | 3 | # BM 4 | 5 | # Sunday 6 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/.DS_Store -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/08~附录/08.05.md: -------------------------------------------------------------------------------- 1 | ## 网络协议 2 | 3 | **1** 4 | 5 | 请简单阐述TCP连接的三次握手。 6 | -------------------------------------------------------------------------------- /03~图论/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/03~图论/.DS_Store -------------------------------------------------------------------------------- /03~排序/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/03~排序/.DS_Store -------------------------------------------------------------------------------- /01~算法基础/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/01~算法基础/.DS_Store -------------------------------------------------------------------------------- /02~数据结构/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/02~数据结构/.DS_Store -------------------------------------------------------------------------------- /03~图论/README.md: -------------------------------------------------------------------------------- 1 | # 图论 2 | 3 | # Links 4 | 5 | - https://mp.weixin.qq.com/s/MeG3nLT0D8Q4DWBAIrc0Xw 6 | -------------------------------------------------------------------------------- /03~查找与搜索/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/03~查找与搜索/.DS_Store -------------------------------------------------------------------------------- /99~参考资料/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/99~参考资料/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.xmind filter=lfs diff=lfs merge=lfs -text 2 | *.pdf filter=lfs diff=lfs merge=lfs -text 3 | -------------------------------------------------------------------------------- /02~数据结构/数组/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/02~数据结构/数组/.DS_Store -------------------------------------------------------------------------------- /02~数据结构/数组/滑动窗口/README.md: -------------------------------------------------------------------------------- 1 | # 滑动窗口 2 | 3 | # Links 4 | 5 | - https://www.itcodemonkey.com/article/15268.html 6 | -------------------------------------------------------------------------------- /02~数据结构/栈与队列/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/02~数据结构/栈与队列/.DS_Store -------------------------------------------------------------------------------- /03~排序/REAMDE.md: -------------------------------------------------------------------------------- 1 | # 排序算法 2 | 3 | # Links 4 | 5 | - https://www.zhihu.com/question/23148377/answer/714596562 6 | -------------------------------------------------------------------------------- /03~图论/图遍历/README.md: -------------------------------------------------------------------------------- 1 | # 图遍历 2 | 3 | ![](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/item/20230510140241.png) 4 | -------------------------------------------------------------------------------- /99~参考资料/王道~《数据结构》/数据结构.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/99~参考资料/王道~《数据结构》/数据结构.pdf -------------------------------------------------------------------------------- /02~数据结构/字符串/Base64/README.md: -------------------------------------------------------------------------------- 1 | # Base64 2 | 3 | # Links 4 | 5 | - https://blog.csdn.net/wo541075754/article/details/81734770 6 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/06~海量数据处理/06.10.md: -------------------------------------------------------------------------------- 1 | # 数据库 2 | 3 | ## 方法介绍 4 | 5 | 当遇到大数据量的增删改查时,一般把数据装进数据库中,从而利用数据的设计实现方法,对海量数据的增删改查进行处理。 6 | -------------------------------------------------------------------------------- /02~数据结构/栈与队列/时间轮/README.md: -------------------------------------------------------------------------------- 1 | # 时间轮 2 | 3 | # Links 4 | 5 | - https://mp.weixin.qq.com/s/xIWKcWCV_eyH-vQOQWxGUw 时间轮在 Kafka 的实践 6 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/java/chapter3/IFindMinK.java: -------------------------------------------------------------------------------- 1 | interface IFindMinK { 2 | public int[] findMinK(int[] data, int k); 3 | } 4 | -------------------------------------------------------------------------------- /99~参考资料/王道~《数据结构》/数据结构知识框架.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/99~参考资料/王道~《数据结构》/数据结构知识框架.xmind -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/04~查找匹配/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/Algorithm-Notes/master/99~参考资料/《程序员编程技艺》/04~查找匹配/.DS_Store -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/java/chapter2/ICompare.java: -------------------------------------------------------------------------------- 1 | interface ICompare { 2 | public boolean compare(String longStr, String shortStr); 3 | } 4 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/ruby/chapter19.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # -*- coding: UTF-8 -*- 3 | # see 'chapter04.rb' 4 | # String.o_first_count_letter -------------------------------------------------------------------------------- /03~排序/树形排序/桶排序.md: -------------------------------------------------------------------------------- 1 | # Bucket Sorting: 桶排序 2 | 3 | > 4 | 5 | - [经典排序算法 - 桶排序 Bucket sort](http://www.cnblogs.com/kkun/archive/2011/11/23/2260267.html) 6 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "10" 4 | before_install: 5 | - npm i -g lint-md-cli 6 | script: lint-md ./ 7 | -------------------------------------------------------------------------------- /02~数据结构/字符串/JSON/99~参考资料/2023~Building a high performance JSON parser.md: -------------------------------------------------------------------------------- 1 | > [原文地址](https://dave.cheney.net/paste/gophercon-sg-2023.html) 2 | 3 | # Building a high performance JSON parser 4 | -------------------------------------------------------------------------------- /02~数据结构/哈希表/过滤器/CuckooFilter.md: -------------------------------------------------------------------------------- 1 | # Cuckoo Filter 2 | 3 | # Links 4 | 5 | - [Cuckoo Filter:设计与实现](http://coolshell.cn/articles/17225.html) > [CFilter](https://github.com/irfansharif/cfilter) 6 | -------------------------------------------------------------------------------- /02~数据结构/字符串/Trie/README.md: -------------------------------------------------------------------------------- 1 | # Trie 2 | 3 | # Links 4 | 5 | - [6 天通吃树结构:第五天 Trie 树](http://www.cnblogs.com/huangxincheng/archive/2012/11/25/2788268.html) 6 | - [Trie 树(字典树)](http://6me.us/YQDF3) 7 | -------------------------------------------------------------------------------- /02~数据结构/压缩/zlib/README.md: -------------------------------------------------------------------------------- 1 | # zlib 2 | 3 | zlib 是提供资料压缩之用的函式库,由 Jean-loup Gailly 与 Mark Adler 所开发,初版 0.9 版在 1995 年 5 月 1 日发表。zlib 使用 DEFLATE 算法,最初是为 libpng 函式库所写的,后来普遍为许多软件所使用。此函式库为自由软件,使用 zlib 授权。 4 | -------------------------------------------------------------------------------- /03~查找与搜索/查找树/Trie/README.md: -------------------------------------------------------------------------------- 1 | # Trie 2 | 3 | # Links 4 | 5 | - [6 天通吃树结构:第五天 Trie 树](http://www.cnblogs.com/huangxincheng/archive/2012/11/25/2788268.html) 6 | - [Trie 树(字典树)](http://6me.us/YQDF3) 7 | -------------------------------------------------------------------------------- /03~查找与搜索/查找树/红黑树/README.md: -------------------------------------------------------------------------------- 1 | # 红黑树 2 | 3 | # Links 4 | 5 | - https://mp.weixin.qq.com/s/ojMopDaSf9sSWmMiC0_U1w 图解“红黑树”原理,一看就明白! 6 | - https://blog.csdn.net/v_july_v/article/details/6105630 教你初步了解红黑树 7 | -------------------------------------------------------------------------------- /02~数据结构/数组/滑动窗口/滑动窗口均值/go.mod: -------------------------------------------------------------------------------- 1 | module code.go 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/shomali11/go-interview v0.0.0-20200725150355-434db55b01dd 7 | github.com/stretchr/testify v1.5.1 8 | ) 9 | -------------------------------------------------------------------------------- /03~排序/分配排序/基数排序.md: -------------------------------------------------------------------------------- 1 | # 基数排序 2 | 3 | ## Complexity:算法复杂度 4 | 5 | ### 稳定性 6 | 7 | 基数排序是按照低位先排序,然后收集;再按照高位排序,然后再收集;依次类推,直到最高位。有时候有些属性是有优先级顺序的,先按低优先级排序,再按高优 8 | 先级排序,最后的次序就是高优先级高的在前,高优先级相同的低优先级高的在前。基数排序基于分别排序,分别收集,所以其是稳定的排序算法。 9 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/emc_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/emc_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.016487580637467636, https://leetcode.com/problems/two-sum 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/fallible_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 507,Perfect Number,35.5%,Easy,0, https://leetcode.com/problems/perfect-number 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/inmobi_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 754,Reach a Number,34.7%,Medium,0, https://leetcode.com/problems/reach-a-number 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/radius_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/valve_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 3 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/python/6.5:全排列.py: -------------------------------------------------------------------------------- 1 | import itertools 2 | if __name__ == "__main__": 3 | line = raw_input("please input some char:\n") 4 | for i in itertools.permutations(list(line)): 5 | print "".join(i) 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/fidessa_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 888,Fair Candy Swap,58.5%,Easy,0, https://leetcode.com/problems/fair-candy-swap 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/ge-digital_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.00184543512358731, https://leetcode.com/problems/two-sum 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/groupon_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/hotstar_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 927,Three Equal Parts,33.6%,Hard,0, https://leetcode.com/problems/three-equal-parts 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/limebike_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 980,Unique Paths III,73.3%,Hard,0, https://leetcode.com/problems/unique-paths-iii 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/samsung_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.001767235914611495, https://leetcode.com/problems/two-sum 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zscaler_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1154,Day of the Year,49.3%,Easy,0, https://leetcode.com/problems/day-of-the-year 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/arista_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 997,Find the Town Judge,50.1%,Easy,0, https://leetcode.com/problems/find-the-town-judge 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/booking_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1034,Coloring A Border,44.7%,Medium,0, https://leetcode.com/problems/coloring-a-border 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/bytedancetoutiao_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1140,Stone Game II,63.3%,Medium,0, https://leetcode.com/problems/stone-game-ii 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/pramp_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1229,Meeting Scheduler,52.7%,Medium,0, https://leetcode.com/problems/meeting-scheduler 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/works-applications_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.00184543512358731, https://leetcode.com/problems/two-sum 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zappos_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 322,Coin Change,35.5%,Medium,0.00904437880665999, https://leetcode.com/problems/coin-change 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zappos_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 322,Coin Change,35.5%,Medium,0.00904437880665999, https://leetcode.com/problems/coin-change 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/dell_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 706,Design HashMap,61.3%,Easy,0.016660110451195708, https://leetcode.com/problems/design-hashmap 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/f5-networks_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1291,Sequential Digits,53.4%,Medium,0, https://leetcode.com/problems/sequential-digits 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/gilt-groupe_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 623,Add One Row to Tree,49.7%,Medium,0, https://leetcode.com/problems/add-one-row-to-tree 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/godaddy_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 139,Word Break,40.1%,Medium,0.003894465052690167, https://leetcode.com/problems/word-break 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/helix_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 696,Count Binary Substrings,56.0%,Easy,0, https://leetcode.com/problems/count-binary-substrings 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/quantcast_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 79,Word Search,35.6%,Medium,0.0016647248725526849, https://leetcode.com/problems/word-search 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/dataminr_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 57,Insert Interval,33.5%,Hard,0.013119243592498872, https://leetcode.com/problems/insert-interval 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/quantcast_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 79,Word Search,35.6%,Medium,0.0016647248725526849, https://leetcode.com/problems/word-search 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/rackspace_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 473,Matchsticks to Square,37.7%,Medium,0, https://leetcode.com/problems/matchsticks-to-square 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/airtel_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1310,XOR Queries of a Subarray,68.7%,Medium,0, https://leetcode.com/problems/xor-queries-of-a-subarray 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/blizzard_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/blizzard_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 20,Valid Parentheses,39.0%,Easy,0.055983722381420686, https://leetcode.com/problems/valid-parentheses 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/ibm_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 88,Merge Sorted Array,39.4%,Easy,0.0030102370714243072, https://leetcode.com/problems/merge-sorted-array 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/jump-trading_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 224,Basic Calculator,36.8%,Hard,0.0200809960570491, https://leetcode.com/problems/basic-calculator 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/jump-trading_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 224,Basic Calculator,36.8%,Hard,0.0200809960570491, https://leetcode.com/problems/basic-calculator 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/mckinsey_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 934,Shortest Bridge,48.2%,Medium,0.03607244121670154, https://leetcode.com/problems/shortest-bridge 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/poynt_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 655,Print Binary Tree,55.0%,Medium,0.11153609770197609, https://leetcode.com/problems/print-binary-tree 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/sapient_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 891,Sum of Subsequence Widths,31.9%,Hard,0, https://leetcode.com/problems/sum-of-subsequence-widths 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/wayfair_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 85,Maximal Rectangle,37.7%,Hard,0.012771565679487524, https://leetcode.com/problems/maximal-rectangle 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zalando_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 984,String Without AAA or BBB,37.7%,Medium,0, https://leetcode.com/problems/string-without-aaa-or-bbb 3 | -------------------------------------------------------------------------------- /03~排序/外部排序/README.md: -------------------------------------------------------------------------------- 1 | # 大数据外部排序 2 | 3 | ![](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/item/20230417221554.png) 4 | 5 | # Links 6 | 7 | - https://github.com/lemire/externalsortinginjava 8 | - https://mp.weixin.qq.com/s/V1mNZsqi008OmIHk0E56FA 9 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/affinity_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1106,Parsing A Boolean Expression,58.5%,Hard,0, https://leetcode.com/problems/parsing-a-boolean-expression 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/flexport_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 981,Time Based Key-Value Store,53.1%,Medium,0, https://leetcode.com/problems/time-based-key-value-store 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/grab_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 234,Palindrome Linked List,39.3%,Easy,0.004533613114828982, https://leetcode.com/problems/palindrome-linked-list 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/iit-bombay_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 861,Score After Flipping Matrix,72.8%,Medium,0, https://leetcode.com/problems/score-after-flipping-matrix 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/jingchi_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 772,Basic Calculator III,41.3%,Hard,0.06331227941432688, https://leetcode.com/problems/basic-calculator-iii 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/snapdeal_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1027,Longest Arithmetic Sequence,53.4%,Medium,0, https://leetcode.com/problems/longest-arithmetic-sequence 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/thumbtack_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 966,Vowel Spellchecker,47.2%,Medium,1.030624947683177, https://leetcode.com/problems/vowel-spellchecker 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/twitch_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 695,Max Area of Island,62.7%,Medium,0.012686500631003836, https://leetcode.com/problems/max-area-of-island 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/yatra_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 713,Subarray Product Less Than K,39.1%,Medium,0, https://leetcode.com/problems/subarray-product-less-than-k 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/electronic-arts_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 206,Reverse Linked List,62.5%,Easy,0.0023398665252948926, https://leetcode.com/problems/reverse-linked-list 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/huawei_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 617,Merge Two Binary Trees,74.1%,Easy,0.007927112458083044, https://leetcode.com/problems/merge-two-binary-trees 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/national-instruments_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 880,Decoded String at Index,24.3%,Medium,0, https://leetcode.com/problems/decoded-string-at-index 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/palantir_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1232,Check If It Is a Straight Line,45.3%,Easy,0, https://leetcode.com/problems/check-if-it-is-a-straight-line 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/riot-games_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 29,Divide Two Integers,16.4%,Medium,0.006772799340092467, https://leetcode.com/problems/divide-two-integers 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/akamai_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 961,N-Repeated Element in Size 2N Array,73.7%,Easy,0, https://leetcode.com/problems/n-repeated-element-in-size-2n-array 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/clutter_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1181,Before and After Puzzle,44.5%,Medium,5.639540205927847, https://leetcode.com/problems/before-and-after-puzzle 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/factset_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 168,Excel Sheet Column Title,31.1%,Easy,0.01734648872385377, https://leetcode.com/problems/excel-sheet-column-title 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/machinezone_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1336,Number of Transactions per Visit,43.7%,Hard,0, https://leetcode.com/problems/number-of-transactions-per-visit 3 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/6.6:跳台阶问题.c: -------------------------------------------------------------------------------- 1 | //解法一 2 | long long Fibonacci_Solution1(unsigned int n) 3 | { 4 | int result[2] = {0, 1, 2}; 5 | if (n <= 2) 6 | return result[n]; 7 | 8 | return Fibonacci_Solution1(n - 1) + Fibonacci_Solution1(n - 2); 9 | } 10 | -------------------------------------------------------------------------------- /02~数据结构/数组/滑动窗口/滑动窗口均值/README.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | Given a stream of integers, calculate the moving average within a fixed sliding window 4 | 5 | ### Example 1: 6 | 7 | ``` 8 | Input: Numbers 1, 2, 3, 4, 5 - Sliding Window of 3 9 | Output: 4 10 | ``` 11 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/jane-street_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 874,Walking Robot Simulation,35.2%,Easy,0.09860197680453955, https://leetcode.com/problems/walking-robot-simulation 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/leap-motion_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 478,Generate Random Point in a Circle,38.5%,Medium,0, https://leetcode.com/problems/generate-random-point-in-a-circle 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/phonepe_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1202,Smallest String With Swaps,46.5%,Medium,0.09740053011838201, https://leetcode.com/problems/smallest-string-with-swaps 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/traveloka_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1208,Get Equal Substrings Within Budget,41.9%,Medium,0, https://leetcode.com/problems/get-equal-substrings-within-budget 3 | -------------------------------------------------------------------------------- /02~数据结构/栈与队列/LRU.md: -------------------------------------------------------------------------------- 1 | # LRU 2 | 3 | # Links 4 | 5 | - https://blog.csdn.net/kuizhu7142/article/details/81115750 6 | - https://github.com/labuladong/fucking-algorithm/blob/master/%E9%AB%98%E9%A2%91%E9%9D%A2%E8%AF%95%E7%B3%BB%E5%88%97/LRU%E7%AE%97%E6%B3%95.md 层层拆解,带你手写 LRU 算法 7 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/druva_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1005,Maximize Sum Of Array After K Negations,51.3%,Easy,0, https://leetcode.com/problems/maximize-sum-of-array-after-k-negations 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/meituan_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 847,Shortest Path Visiting All Nodes,52.0%,Hard,0.1541506798272583, https://leetcode.com/problems/shortest-path-visiting-all-nodes 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/paytm_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1047,Remove All Adjacent Duplicates In String,68.6%,Easy,0, https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/pocket-gems_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 366,Find Leaves of Binary Tree,70.6%,Medium,0.19526527689524323, https://leetcode.com/problems/find-leaves-of-binary-tree 3 | -------------------------------------------------------------------------------- /01~算法基础/README.md: -------------------------------------------------------------------------------- 1 | # 算法基础 2 | 3 | 算法(Algorithm)是为了解决一个特定的问题而精心设计的一套数学模型以及在这套数学模型上的一系列操作步骤,这些操作步骤是将描述的输入数据逐步处理、转换,并最后得到一个确定的结果。当然,准确性是基本前提,时间和空间效率是衡量一个算法优劣的重要评估标准。算法通常在函数中使用控制结构来实现。 4 | 5 | # Links 6 | 7 | - https://mp.weixin.qq.com/s/gC-w-4_FfGxtfQ79mtpbFg 95% 的算法都是基于这 6 种算法思想 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/accolite_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1234,Replace the Substring for Balanced String,33.2%,Medium,0, https://leetcode.com/problems/replace-the-substring-for-balanced-string 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/akuna_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 995,Minimum Number of K Consecutive Bit Flips,46.8%,Hard,0, https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/jp-morgan-chase_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1247,Minimum Swaps to Make Strings Equal,60.1%,Medium,0, https://leetcode.com/problems/minimum-swaps-to-make-strings-equal 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/maq-software_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 467,Unique Substrings in Wraparound String,35.6%,Medium,0, https://leetcode.com/problems/unique-substrings-in-wraparound-string 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/meituan_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 847,Shortest Path Visiting All Nodes,52.0%,Hard,0.1541506798272583, https://leetcode.com/problems/shortest-path-visiting-all-nodes 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/microstrategy_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1227,Airplane Seat Assignment Probability,61.0%,Medium,0, https://leetcode.com/problems/airplane-seat-assignment-probability 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/opendoor_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 150,Evaluate Reverse Polish Notation,36.3%,Medium,0.031526253646773944, https://leetcode.com/problems/evaluate-reverse-polish-notation 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/qualcomm_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 160,Intersection of Two Linked Lists,40.6%,Easy,0.01052764431315656, https://leetcode.com/problems/intersection-of-two-linked-lists 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/symantec_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 628,Maximum Product of Three Numbers,47.1%,Easy,0.016529301951210565, https://leetcode.com/problems/maximum-product-of-three-numbers 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/symantec_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 628,Maximum Product of Three Numbers,47.1%,Easy,0.03681397312271631, https://leetcode.com/problems/maximum-product-of-three-numbers 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/tandemg_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 915,Partition Array into Disjoint Intervals,45.4%,Medium,0, https://leetcode.com/problems/partition-array-into-disjoint-intervals 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/forusall_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 272,Closest Binary Search Tree Value II,50.5%,Hard,0.08994823666293948, https://leetcode.com/problems/closest-binary-search-tree-value-ii 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/kakao_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1210,Minimum Moves to Reach Target with Rotations,45.2%,Hard,0, https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/walmart_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1238,Circular Permutation in Binary Representation,65.0%,Medium,0, https://leetcode.com/problems/circular-permutation-in-binary-representation 3 | -------------------------------------------------------------------------------- /01~算法基础/算法思维/递推法.md: -------------------------------------------------------------------------------- 1 | # 递推法 Recurrence method 2 | 3 | 与枚举算法思想相比,递推算法能够通过已知的某个条件,利用特定的关系得出中间推论,然后逐步递推,直到得到结果为止。由此可见,递推算法要比枚举算法聪明,它不会尝试每种可能的方案。递推算法可以不断利用已有的信息推导出新的东西,在日常应用中有如下两种递推算法: 4 | 5 | - 顺推法:从已知条件出发,逐步推算出要解决问题的方法。例如斐波那契数列就可以通过顺推法不断递推算出新的数据。 6 | - 逆推法:从已知的结果出发,用迭代表达式逐步推算出问题开始的条件,即顺推法的逆过程。 7 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zillow_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 236,Lowest Common Ancestor of a Binary Tree,45.7%,Medium,0.004507557778555423, https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/codenation_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1330,Reverse Subarray To Maximize Array Value,35.2%,Hard,0.29849298855599654, https://leetcode.com/problems/reverse-subarray-to-maximize-array-value 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/deliveryhero_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1276,Number of Burgers with No Waste of Ingredients,49.7%,Medium,0, https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/alation_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 3,Longest Substring Without Repeating Characters,30.4%,Medium,0.003496778759264278, https://leetcode.com/problems/longest-substring-without-repeating-characters 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/alation_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 3,Longest Substring Without Repeating Characters,30.4%,Medium,0.009683242444739549, https://leetcode.com/problems/longest-substring-without-repeating-characters 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/alation_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 3,Longest Substring Without Repeating Characters,30.4%,Medium,0.14469274653374686, https://leetcode.com/problems/longest-substring-without-repeating-characters 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/bloomreach_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1111,Maximum Nesting Depth of Two Valid Parentheses Strings,70.4%,Medium,0, https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/valve_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.0073613942765888805, https://leetcode.com/problems/two-sum 3 | 649,Dota2 Senate,39.2%,Medium,0, https://leetcode.com/problems/dota2-senate 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/radius_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.0051178232035212715, https://leetcode.com/problems/two-sum 3 | 724,Find Pivot Index,44.0%,Easy,0, https://leetcode.com/problems/find-pivot-index 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/alibaba_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 146,LRU Cache,33.2%,Medium,0.00369087024717462, https://leetcode.com/problems/lru-cache 3 | 1,Two Sum,45.6%,Easy,0.00184543512358731, https://leetcode.com/problems/two-sum 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/ge-digital_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.003278422738041615, https://leetcode.com/problems/two-sum 3 | 697,Degree of an Array,53.8%,Easy,0, https://leetcode.com/problems/degree-of-an-array 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/aetion_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 2,Add Two Numbers,33.9%,Medium,0.001641227730374625, https://leetcode.com/problems/add-two-numbers 3 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 4 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/01~字符串/01.00.md: -------------------------------------------------------------------------------- 1 | ## 本章导读 2 | 3 | 字符串相关的问题在各大互联网公司笔试面试中出现的频率极高,比如微软经典的单词翻转题:输入“I am a student.”,则输出“student. a am I”。 4 | 5 | 本章重点介绍6个经典的字符串问题,分别是旋转字符串、字符串包含、字符串转换成整数、回文判断、最长回文子串、字符串的全排列,这6个问题要么从暴力解法入手,然后逐步优化,要么多种思路多种解法。 6 | 7 | 读完本章后会发现,好的思路都是在充分考虑到问题本身的特征的前提下,或巧用合适的数据结构,或选择合适的算法降低时间复杂度(避免不必要的操作),或选用效率更高的算法。 8 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CPPFLAGS = -Wall 3 | 4 | FILE_SUFFIX = c 5 | 6 | SRCS := $(wildcard *.$(FILE_SUFFIX)) 7 | EXES := $(patsubst %.$(FILE_SUFFIX),%,$(SRCS)) 8 | 9 | all:$(EXES) 10 | 11 | $(EXES): % : %.$(FILE_SUFFIX) 12 | $(CC) $(CPPFLAGS) $< -o $@ 13 | 14 | clean: 15 | rm -rf $(EXES) 16 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/cpp/makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | CPPFLAGS = -Wall 3 | 4 | FILE_SUFFIX = cpp 5 | 6 | SRCS := $(wildcard *.$(FILE_SUFFIX)) 7 | EXES := $(patsubst %.$(FILE_SUFFIX),%,$(SRCS)) 8 | 9 | all:$(EXES) 10 | 11 | $(EXES): % : %.$(FILE_SUFFIX) 12 | $(CC) $(CPPFLAGS) $< -o $@ 13 | 14 | clean: 15 | rm -rf $(EXES) 16 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/honey_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1239,Maximum Length of a Concatenated String with Unique Characters,47.8%,Medium,0.0766985653316095, https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters 3 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/hulu_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 326,Power of Three,42.1%,Easy,0.009758240486961556, https://leetcode.com/problems/power-of-three 3 | 394,Decode String,50.0%,Medium,0.004879120243480778, https://leetcode.com/problems/decode-string 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/liveramp_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 529,Minesweeper,59.1%,Medium,0.004395364661211742, https://leetcode.com/problems/minesweeper 3 | 20,Valid Parentheses,39.0%,Easy,0.002197682330605871, https://leetcode.com/problems/valid-parentheses 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/poshmark_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1159,Market Analysis II,52.9%,Hard,0.15535044001916237, https://leetcode.com/problems/market-analysis-ii 3 | 1158,Market Analysis I,61.7%,Medium,0, https://leetcode.com/problems/market-analysis-i 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/cloudera_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 622,Design Circular Queue,43.7%,Medium,0.001641227730374625, https://leetcode.com/problems/design-circular-queue 3 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/robinhood_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 224,Basic Calculator,36.8%,Hard,0.012377921514712346, https://leetcode.com/problems/basic-calculator 3 | 54,Spiral Matrix,34.1%,Medium,0.006188960757356173, https://leetcode.com/problems/spiral-matrix 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/uipath_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1036,Escape a Large Maze,35.4%,Hard,0, https://leetcode.com/problems/escape-a-large-maze 3 | 1162,As Far from Land as Possible,43.5%,Medium,0, https://leetcode.com/problems/as-far-from-land-as-possible 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/barclays_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 509,Fibonacci Number,67.2%,Easy,0.010337721155330612, https://leetcode.com/problems/fibonacci-number 3 | 20,Valid Parentheses,39.0%,Easy,0.005168860577665306, https://leetcode.com/problems/valid-parentheses 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/c3-iot_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 930,Binary Subarrays With Sum,43.2%,Medium,0, https://leetcode.com/problems/binary-subarrays-with-sum 3 | 976,Largest Perimeter Triangle,57.6%,Easy,0, https://leetcode.com/problems/largest-perimeter-triangle 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/epic-systems_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 306,Additive Number,29.4%,Medium,0.013188310235026049, https://leetcode.com/problems/additive-number 3 | 54,Spiral Matrix,34.1%,Medium,0.0065941551175130245, https://leetcode.com/problems/spiral-matrix 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/tableau_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 706,Design HashMap,61.3%,Easy,0.005779515653180723, https://leetcode.com/problems/design-hashmap 3 | 200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands 4 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/java/chapter3/HeapSolution.java: -------------------------------------------------------------------------------- 1 | class HeapSolution implements IFindMinK { 2 | 3 | @Override 4 | public int[] findMinK(int[] data, int k) { 5 | MaxHeap heap = new MaxHeap(k); 6 | for (int n : data) { 7 | heap.insert(n); 8 | } 9 | return heap.getAll(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/garena_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 46,Permutations,63.5%,Medium,0.0006322825600889028, https://leetcode.com/problems/permutations 3 | 4,Median of Two Sorted Arrays,29.6%,Hard,0.0003161412800444514, https://leetcode.com/problems/median-of-two-sorted-arrays 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/machine-zone_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 715,Range Module,38.5%,Hard,0.33647223662121295, https://leetcode.com/problems/range-module 3 | 1336,Number of Transactions per Visit,43.7%,Hard,0, https://leetcode.com/problems/number-of-transactions-per-visit 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/riot-games_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 29,Divide Two Integers,16.4%,Medium,0.010337721155330612, https://leetcode.com/problems/divide-two-integers 3 | 20,Valid Parentheses,39.0%,Easy,0.005168860577665306, https://leetcode.com/problems/valid-parentheses 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/turvo_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1335,Minimum Difficulty of a Job Schedule,57.6%,Hard,0, https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule 3 | 1534,Count Good Triplets,79.6%,Easy,0, https://leetcode.com/problems/count-good-triplets 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/cohesity_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 76,Minimum Window Substring,34.6%,Hard,0.009473078693346433, https://leetcode.com/problems/minimum-window-substring 3 | 207,Course Schedule,43.1%,Medium,0.004736539346673217, https://leetcode.com/problems/course-schedule 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zappos_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 557,Reverse Words in a String III,69.8%,Easy,0.03063547953861342, https://leetcode.com/problems/reverse-words-in-a-string-iii 3 | 322,Coin Change,35.5%,Medium,0.016022774188122292, https://leetcode.com/problems/coin-change 4 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/src/java/main/IArraySort.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by corning on 2017/12/19. 3 | */ 4 | public interface IArraySort { 5 | /** 6 | * 对数组进行排序,并返回排序后的数组 7 | * 8 | * @param sourceArray 9 | * @return 10 | * @throws Exception 11 | */ 12 | int[] sort(int[] sourceArray) throws Exception; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/splunk_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 977,Squares of a Sorted Array,72.1%,Easy,0.0030708129315390595, https://leetcode.com/problems/squares-of-a-sorted-array 3 | 20,Valid Parentheses,39.0%,Easy,0.0015354064657695297, https://leetcode.com/problems/valid-parentheses 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/airbnb_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 864,Shortest Path to Get All Keys,40.1%,Hard,0.13271866487392153, https://leetcode.com/problems/shortest-path-to-get-all-keys 3 | 251,Flatten 2D Vector,45.7%,Medium,0.06635933243696077, https://leetcode.com/problems/flatten-2d-vector 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/arista-networks_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 165,Compare Version Numbers,27.4%,Medium,0.005779515653180723, https://leetcode.com/problems/compare-version-numbers 3 | 200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/coursera_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 68,Text Justification,27.7%,Hard,0.013771787933090317, https://leetcode.com/problems/text-justification 3 | 10,Regular Expression Matching,26.8%,Hard,0.006885893966545159, https://leetcode.com/problems/regular-expression-matching 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/infosys_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1124,Longest Well-Performing Interval,32.7%,Medium,0, https://leetcode.com/problems/longest-well-performing-interval 3 | 1540,Can Convert String in K Moves,27.2%,Medium,0, https://leetcode.com/problems/can-convert-string-in-k-moves 4 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/scheme/chapter01.scm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/guile -s 2 | !# 3 | 4 | (define (leftshift str n) 5 | (display 6 | (reverse (append (reverse (string->list (substring str 0 (- (string-length str) n)))) 7 | (reverse (string->list (substring str (- (string-length str) n) (string-length str)))))))) 8 | 9 | (leftshift "helloworld" 3) 10 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | 1. [冒泡排序](1.bubbleSort.md) 4 | 2. [选择排序](2.selectionSort.md) 5 | 3. [插入排序](3.insertionSort.md) 6 | 4. [希尔排序](4.shellSort.md) 7 | 5. [归并排序](5.mergeSort.md) 8 | 6. [快速排序](6.quickSort.md) 9 | 7. [堆排序](7.heapSort.md) 10 | 8. [计数排序](8.countingSort.md) 11 | 9. [桶排序](9.bucketSort.md) 12 | 10. [基数排序](10.radixSort.md) 13 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/c3ai_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1220,Count Vowels Permutation,54.0%,Hard,0.6794349186959634, https://leetcode.com/problems/count-vowels-permutation 3 | 1419,Minimum Number of Frogs Croaking,46.3%,Medium,0, https://leetcode.com/problems/minimum-number-of-frogs-croaking 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/medianet_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1222,Queens That Can Attack the King,68.8%,Medium,0, https://leetcode.com/problems/queens-that-can-attack-the-king 3 | 1266,Minimum Time Visiting All Points,79.6%,Easy,0, https://leetcode.com/problems/minimum-time-visiting-all-points 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/reddit_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 314,Binary Tree Vertical Order Traversal,45.3%,Medium,0.0346478998635486, https://leetcode.com/problems/binary-tree-vertical-order-traversal 3 | 289,Game of Life,54.5%,Medium,0.0173239499317743, https://leetcode.com/problems/game-of-life 4 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/ruby/chapter17.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # -*- coding: UTF-8 -*- 3 | 4 | def fibonacci_solution n 5 | return [0, 1, 2][n] if( n <= 2 ) 6 | fibonacci_solution(n - 1) + fibonacci_solution( n - 2) 7 | end 8 | 9 | if __FILE__ == $0 10 | steps = [1, 2, 3, 4, 5, 6] 11 | p steps.map{|x| 12 | [x, fibonacci_solution(x)] 13 | } 14 | 15 | end -------------------------------------------------------------------------------- /02~数据结构/README.md: -------------------------------------------------------------------------------- 1 | # 数据结构 2 | 3 | 数据结构是一门研究非数值计算的程序设计问题中的操作对象,以及它们之间关系和操作等相关问题的学科。**程序设计 = 数据结构 + 算法**。数据结构中基本的概念有: 4 | 5 | - 数据:描述客观事物的符号,是计算机中可以操作的对象,是能被计算机识别,并输入给计算机处理的符号集合。 6 | - 数据元素:组成数据的,有一定意义的基本单位,在计算机中通常作为整体处理,也被成为记录。 7 | - 数据项:一个数据元素由若干个数据项构成,数据项是数据不可分割的最小元素。 8 | - 数据对象:性质相同的数据元素的集合,是数据的子集。 9 | - 数据结构:数据结构是相互之间存在一种或多种特定关系的数据元素的集合,不同数据元素之间不是独立的,而是存在这特定的关系,这些关系成为结构。 10 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/triplebyte_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 348,Design Tic-Tac-Toe,54.3%,Medium,0.02840060345824747, https://leetcode.com/problems/design-tic-tac-toe 3 | 230,Kth Smallest Element in a BST,60.2%,Medium,0.014200301729123736, https://leetcode.com/problems/kth-smallest-element-in-a-bst 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/netsuite_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 577,Employee Bonus,68.2%,Easy,0, https://leetcode.com/problems/employee-bonus 3 | 1491,Average Salary Excluding the Minimum and Maximum Salary,70.3%,Easy,0, https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/triplebyte_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 348,Design Tic-Tac-Toe,54.3%,Medium,0.012672305978993447, https://leetcode.com/problems/design-tic-tac-toe 3 | 230,Kth Smallest Element in a BST,60.2%,Medium,0.0063361529894967236, https://leetcode.com/problems/kth-smallest-element-in-a-bst 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/cruise-automation_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 304,Range Sum Query 2D - Immutable,38.6%,Medium,0.024264780496475645, https://leetcode.com/problems/range-sum-query-2d-immutable 3 | 695,Max Area of Island,62.7%,Medium,0.012132390248237822, https://leetcode.com/problems/max-area-of-island 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/united-health-group_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1185,Day of the Week,64.0%,Easy,0, https://leetcode.com/problems/day-of-the-week 3 | 1437,Check If All 1's Are at Least Length K Places Away,63.3%,Medium,0, https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away 4 | -------------------------------------------------------------------------------- /02~数据结构/栈与队列/多级反馈队列.md: -------------------------------------------------------------------------------- 1 | # 多级反馈队列 2 | 3 | # Links 4 | 5 | - https://github.com/LambdaSchool/Multi-Level-Feedback-Queue/blob/master/src/Scheduler.js 6 | 7 | - https://baike.baidu.com/item/%E5%A4%9A%E7%BA%A7%E5%8F%8D%E9%A6%88%E9%98%9F%E5%88%97%E8%B0%83%E5%BA%A6%E7%AE%97%E6%B3%95/449587?fr=aladdin 8 | 9 | - https://github.com/vishnu856/MLFQ-Scheduler-Simulator/blob/master/Code/Process.java 10 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/akuna-capital_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1411,Number of Ways to Paint N × 3 Grid,61.1%,Hard,0.20425899015275967, https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid 3 | 1223,Dice Roll Simulation,45.6%,Medium,0.10212949507637983, https://leetcode.com/problems/dice-roll-simulation 4 | -------------------------------------------------------------------------------- /02~数据结构/哈希表/过滤器/SuRF.md: -------------------------------------------------------------------------------- 1 | # SuRF 2 | 3 | SuRF 是一种查询效率高、压缩比高的字典树(Trie)数据结构,其功能十分简单,提供过滤器的功能。众所周知,BloomFilter 被广泛用于单点过滤——用于判断单个 key 是否存在于集合中。而 SuRF 的不仅拥有单点过滤功能,还能支持范围查询这个大杀器,即其能根据给出的 key 范围来判断其是否在集合中。SuRF 是一种 Trie 树结构,Trie 树的结构使其能支持范围查询,但传统 Trie 树所占空间太大,效率低,在数据库里实际运用很少。SuRF 的突破创新点是其拥有极限小的空间,其 trie 树的每个节点平均只需要占 10bit 空间,而且同时保持了很高的查询性能,构造性能。SuRF 团队将 SuRF 运用到了目前十分受欢迎的 NoSQL 系统 RocksDB 之中,在范围查询之中提升了 1.5 倍~5 倍的效率。 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/groupon_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 155,Min Stack,44.5%,Easy,0.0038394278493949765, https://leetcode.com/problems/min-stack 3 | 146,LRU Cache,33.2%,Medium,0.00369087024717462, https://leetcode.com/problems/lru-cache 4 | 1,Two Sum,45.6%,Easy,0.00184543512358731, https://leetcode.com/problems/two-sum 5 | -------------------------------------------------------------------------------- /03~排序/简单排序/insert_sort.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | arr:= [9]int{2,1,4,3,5,9,7,6,8} 7 | 8 | for out:=1; out0 && arr[in-1]>=temp;in--{ 13 | arr[in] = arr[in-1] 14 | } 15 | arr[in] = temp 16 | } 17 | 18 | for sortedvals:= range arr{ 19 | fmt.Println(sortedvals) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/appdynamics_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 346,Moving Average from Data Stream,70.9%,Easy,0.015694908538438895, https://leetcode.com/problems/moving-average-from-data-stream 3 | 380,Insert Delete GetRandom O(1),47.5%,Medium,0.007847454269219447, https://leetcode.com/problems/insert-delete-getrandom-o1 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/redfin_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 628,Maximum Product of Three Numbers,47.1%,Easy,0.009802739879440973, https://leetcode.com/problems/maximum-product-of-three-numbers 3 | 160,Intersection of Two Linked Lists,40.6%,Easy,0.004901369939720486, https://leetcode.com/problems/intersection-of-two-linked-lists 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/alibaba_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.002906760648617138, https://leetcode.com/problems/two-sum 3 | 146,LRU Cache,33.2%,Medium,0.0023892905841572196, https://leetcode.com/problems/lru-cache 4 | 101,Symmetric Tree,46.8%,Easy,0.0011946452920786098, https://leetcode.com/problems/symmetric-tree 5 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/ruby/chapter03.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # -*- coding: UTF-8 -*- 3 | 4 | def top_minimum(list, k) 5 | h = list[0...k] 6 | list[k..-1].each{|v| 7 | h.each_index{|i| 8 | if h[i] > v 9 | h[i] = v; break 10 | end 11 | } 12 | } 13 | h 14 | end 15 | 16 | if __FILE__== $0 17 | list = [ 9, 8, 6, 4, 1, 2, 3 ] 18 | p top_minimum(list, 3) 19 | end 20 | 21 | -------------------------------------------------------------------------------- /02~数据结构/线性表/集合.md: -------------------------------------------------------------------------------- 1 | # 求交集 2 | 3 | 给定两个整数集合 A 和 B,每个集合都包含 20 亿个不同整数,请给出快速计算 A∩B 的算法,算法可使用外存,但是要求占用内存不能超过 4GB。如果这里的整数是 32 位整数,那么每个集合用一个大小 2^32 位的 bitmap 表示,分别遍历集合算出对应 bitmap 后,直接遍历每一字节取交即可。每个 bitmap 的大小是 2^32bit / 2^3(bits per Byte) = 512MB,一共使用 1GB 内存。构造 bitmap 的时候,除去 bitmap 还有 3GB 可以使用,一共可以存储 3 _ 2^30 / 4 = 3 _ 2 ^28 = 8 亿个整数。那每个集合要按每 8 亿个切分到外存中,分成 3 个部分。这样构造的时候每个集合读取 3 次外存,一共读取 6 次。然后如果结果交集很大而且要得到具体整数,也要对结果做切分,最多存储 3 次外存。 4 | -------------------------------------------------------------------------------- /01~算法基础/算法思维/枚举法.md: -------------------------------------------------------------------------------- 1 | # 枚举法 Enumeration method 2 | 3 | 枚举算法思想的最大特点是,在面对任何问题时它会去尝试每一种解决方法。在进行归纳推理时,如果逐个考察了某类事件的所有可能情况,因而得出一般结论,那么这个结论是可靠的,这种归纳方法叫作枚举法。枚举算法的思想是:将问题的所有可能的答案一一列举,然后根据条件判断此答案是否合适,保留合适的,丢弃不合适的。在 C 语言中,枚举算法一般使用 while 循环实现。使用枚举算法解题的基本思路如下。 4 | 5 | - 确定枚举对象、枚举范围和判定条件。 6 | - 逐一列举可能的解,验证每个解是否是问题的解。 7 | 8 | 枚举算法一般按照如下 3 个步骤进行。 9 | 10 | - 题解的可能范围,不能遗漏任何一个真正解,也要避免有重复。 11 | - 判断是否是真正解的方法。 12 | - 使可能解的范围降至最小,以便提高解决问题的效率。 13 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/aetion_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.04892286053064383, https://leetcode.com/problems/two-sum 3 | 413,Arithmetic Slices,57.9%,Medium,0.028431197162004825, https://leetcode.com/problems/arithmetic-slices 4 | 2,Add Two Numbers,33.9%,Medium,0.020491663368639005, https://leetcode.com/problems/add-two-numbers 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/affirm_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 381,Insert Delete GetRandom O(1) - Duplicates allowed,34.1%,Hard,0.01868299433822582, https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed 3 | 380,Insert Delete GetRandom O(1),47.5%,Medium,0.00934149716911291, https://leetcode.com/problems/insert-delete-getrandom-o1 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/dell_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 706,Design HashMap,61.3%,Easy,0.004378252707695627, https://leetcode.com/problems/design-hashmap 3 | 283,Move Zeroes,57.8%,Easy,0.002758622439079723, https://leetcode.com/problems/move-zeroes 4 | 2,Add Two Numbers,33.9%,Medium,0.0016196302686159038, https://leetcode.com/problems/add-two-numbers 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/dell_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 706,Design HashMap,61.3%,Easy,0.009836719431831216, https://leetcode.com/problems/design-hashmap 3 | 283,Move Zeroes,57.8%,Easy,0.006196233249543158, https://leetcode.com/problems/move-zeroes 4 | 2,Add Two Numbers,33.9%,Medium,0.003640486182288058, https://leetcode.com/problems/add-two-numbers 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/nvidia_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 231,Power of Two,43.7%,Easy,0.008651812139809367, https://leetcode.com/problems/power-of-two 3 | 146,LRU Cache,33.2%,Medium,0.004600353139061353, https://leetcode.com/problems/lru-cache 4 | 23,Merge k Sorted Lists,40.2%,Hard,0.004051459000748015, https://leetcode.com/problems/merge-k-sorted-lists 5 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/05~动态规划/05.00.md: -------------------------------------------------------------------------------- 1 | ## 本章导读 2 | 3 | 学习一个算法,可分为3个步骤:首先了解算法本身解决什么问题,然后学习它的解决策略,最后了解某些相似算法之间的联系。例如图算法中, 4 | 5 | - 广搜是一层一层往外遍历,寻找最短路径,其策略是采取队列的方法。 6 | - 最小生成树是最小代价连接所有点,其策略是贪心,比如Prim的策略是贪心+权重队列。 7 | - Dijkstra是寻找单源最短路径,其策略是贪心+非负权重队列。 8 | - Floyd是多结点对的最短路径,其策略是动态规划。 9 | 10 | 而贪心和动态规划是有联系的,贪心是“最优子结构+局部最优”,动态规划是“最优独立重叠子结构+全局最优”。一句话理解动态规划,则是枚举所有状态,然后剪枝,寻找最优状态,同时将每一次求解子问题的结果保存在一张“表格”中,以后再遇到重叠的子问题,从表格中保存的状态中查找(俗称记忆化搜索)。 11 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/postmates_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1190,Reverse Substrings Between Each Pair of Parentheses,61.5%,Medium,0.02893359683550678, https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses 3 | 301,Remove Invalid Parentheses,43.3%,Hard,0.01446679841775339, https://leetcode.com/problems/remove-invalid-parentheses 4 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/2.8:矩阵相乘之Strassen算法.c: -------------------------------------------------------------------------------- 1 | //解法一 2 | //矩阵乘法,3个for循环搞定 3 | void Mul(int** matrixA, int** matrixB, int** matrixC) 4 | { 5 | for(int i = 0; i < 2; ++i) 6 | { 7 | for(int j = 0; j < 2; ++j) 8 | { 9 | matrixC[i][j] = 0; 10 | for(int k = 0; k < 2; ++k) 11 | { 12 | matrixC[i][j] += matrixA[i][k] * matrixB[k][j]; 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/dataminr_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 57,Insert Interval,33.5%,Hard,0.012147643044749783, https://leetcode.com/problems/insert-interval 3 | 56,Merge Intervals,39.3%,Medium,0.007796972706004796, https://leetcode.com/problems/merge-intervals 4 | 42,Trapping Rain Water,48.9%,Hard,0.004350670338744988, https://leetcode.com/problems/trapping-rain-water 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/evernote_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 12,Integer to Roman,55.1%,Medium,0.008045324340891412, https://leetcode.com/problems/integer-to-roman 3 | 202,Happy Number,50.4%,Easy,0.005779515653180723, https://leetcode.com/problems/happy-number 4 | 200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/forusall_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 272,Closest Binary Search Tree Value II,50.5%,Hard,0.3195226783074397, https://leetcode.com/problems/closest-binary-search-tree-value-ii 3 | 828,Count Unique Characters of All Substrings of a Given String,45.2%,Hard,0, https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/garena_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 46,Permutations,63.5%,Medium,0.0006322825600889028, https://leetcode.com/problems/permutations 3 | 4,Median of Two Sorted Arrays,29.6%,Hard,0.0003161412800444514, https://leetcode.com/problems/median-of-two-sorted-arrays 4 | 810,Chalkboard XOR Game,48.2%,Hard,0, https://leetcode.com/problems/chalkboard-xor-game 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/jpmorgan_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1328,Break a Palindrome,43.3%,Medium,0.04449999654894242, https://leetcode.com/problems/break-a-palindrome 3 | 202,Happy Number,50.4%,Easy,0.02483442856330386, https://leetcode.com/problems/happy-number 4 | 20,Valid Parentheses,39.0%,Easy,0.005168860577665306, https://leetcode.com/problems/valid-parentheses 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/riot-games_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 29,Divide Two Integers,16.4%,Medium,0.027386135217402876, https://leetcode.com/problems/divide-two-integers 3 | 37,Sudoku Solver,43.6%,Hard,0.01821543989134118, https://leetcode.com/problems/sudoku-solver 4 | 20,Valid Parentheses,39.0%,Easy,0.009170695326061695, https://leetcode.com/problems/valid-parentheses 5 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/python/2.3:求解500万以内的亲和数_2.py: -------------------------------------------------------------------------------- 1 | if __name__ == "__main__": 2 | n = 10000 * 500 3 | lst = [1 for i in xrange(n)] 4 | # better locality 5 | # using + basic arithmetic, faster than divide 6 | for i in xrange(2, n / 2): 7 | for j in xrange(2 * i, n, i): 8 | lst[j] += i 9 | for i in xrange(2, n): 10 | if lst[i] > i and lst[i] < n and lst[lst[i]] == i: 11 | print i, lst[i] 12 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/dropbox_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 609,Find Duplicate File in System,59.5%,Medium,0.8145843292245993, https://leetcode.com/problems/find-duplicate-file-in-system 3 | 289,Game of Life,54.5%,Medium,0.42762246371793416, https://leetcode.com/problems/game-of-life 4 | 146,LRU Cache,33.2%,Medium,0.040660598211268925, https://leetcode.com/problems/lru-cache 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/pure-storage_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 593,Valid Square,43.1%,Medium,0.15416651566587106, https://leetcode.com/problems/valid-square 3 | 203,Remove Linked List Elements,38.6%,Easy,0.08658586003875597, https://leetcode.com/problems/remove-linked-list-elements 4 | 75,Sort Colors,47.3%,Medium,0.01900520441164089, https://leetcode.com/problems/sort-colors 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/pure-storage_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 593,Valid Square,43.1%,Medium,0.07403645239730852, https://leetcode.com/problems/valid-square 3 | 203,Remove Linked List Elements,38.6%,Easy,0.039410861461804815, https://leetcode.com/problems/remove-linked-list-elements 4 | 75,Sort Colors,47.3%,Medium,0.004785270526301101, https://leetcode.com/problems/sort-colors 5 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/08~附录/08.00.md: -------------------------------------------------------------------------------- 1 | ## 语言基础 2 | 3 | **1**、C++中虚拟函数的实现机制。 4 | 5 | **2**、指针数组和数组指针的区别。 6 | 7 | **3**、malloc-free 和 new-delete 的区别。 8 | 9 | **4**、sizeof 和 strlen 的区别。 10 | 11 | **5**、描述函数调用的整个过程。 12 | 13 | **6**、C++ STL 里面的 vector 的实现机制, 14 | 15 | - 当调用 push_back 成员函数时,怎么实现? 16 | - 内存足则直接 placement new 构造对象,否则扩充内存,转移对象,新对象 placement new 上去。 17 | - 当调用 clear 成员函数时,做什么操作,如果要释放内存该怎么做。 18 | - 调用析构函数,内存不释放。clear 没有释放内存,只是将数组中的元素置为空了,释放内存需要 delete。 19 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/quip_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 708,Insert into a Sorted Circular Linked List,31.6%,Medium,0.00849528727653609, https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list 3 | 34,Find First and Last Position of Element in Sorted Array,36.2%,Medium,0.004247643638268045, https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array 4 | -------------------------------------------------------------------------------- /02~数据结构/线性表/SkipList.md: -------------------------------------------------------------------------------- 1 | # SkipList | 跳表 2 | 3 | Skip List,称之为跳表,它是一种可以替代平衡树的数据结构,其数据元素默认按照 key 值升序,天然有序。Skip list 让已排序的数据分布在多层链表中,以 0-1 随机数决定一个数据的向上攀升与否,通过“空间来换取时间”的一个算法,在每个节点中增加了向前的指针,在插入、删除、查找时可以忽略一些不可能涉及到的结点,从而提高了效率。 4 | 5 | SkipList 具备如下特性: 6 | 7 | 由很多层结构组成,level 是通过一定的概率随机产生的 8 | 每一层都是一个有序的链表,默认是升序,也可以根据创建映射时所提供的 Comparator 进行排序,具体取决于使用的构造方法 9 | 最底层(Level 1)的链表包含所有元素 10 | 如果一个元素出现在 Level i 的链表中,则它在 Level i 之下的链表也都会出现 11 | 每个节点包含两个指针,一个指向同一链表中的下一个元素,一个指向下面一层的元素 12 | -------------------------------------------------------------------------------- /03~图论/最短路径/多段图中的最短路径.md: -------------------------------------------------------------------------------- 1 | # 多段图中的最短路径 2 | 3 | 多段图中的最短路径问题是经典的动态规划问题之一,其可描述为给定一个有向无环图(DAG 图),求给定起始顶点到终止顶点的最短路径,此也属于单源最短路径问题。不过 DAG 的独特之处在于其所有的节点都可以线性化成拓扑序列,使得所有边保持由左到右的方向,譬如下图所示: 4 | 5 | 在文首我们讨论过了,两点之间的最短路径包含最优子结构,即我们可以得出动态规划中的状态转移递推公式。我们关注某个目标顶点 i,到达 i 仅有的途径是经过其直接前驱。如果假设 i 的直接前驱有 k 个顶点:$i_1,i_2,...,i_k$,那我们的状态转移方程可以表述为: 6 | 7 | ``` 8 | dist(i) = min{dist(i1) + d(i1,i),dist(i2) + d(i2,i),...,dist(ik) + d(ik,i)} 9 | ``` 10 | 11 | 其中 d(i,j)是顶点 i 到 j 的边上的权值,dist(源点) = 0。 12 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/blackrock_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 322,Coin Change,35.5%,Medium,0.014188948418642346, https://leetcode.com/problems/coin-change 3 | 12,Integer to Roman,55.1%,Medium,0.008113634774169721, https://leetcode.com/problems/integer-to-roman 4 | 121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/coursera_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 68,Text Justification,27.7%,Hard,0.04141650283478289, https://leetcode.com/problems/text-justification 3 | 10,Regular Expression Matching,26.8%,Hard,0.02726357310890105, https://leetcode.com/problems/regular-expression-matching 4 | 44,Wildcard Matching,24.7%,Hard,0.013110643383019215, https://leetcode.com/problems/wildcard-matching 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/deutsche-bank_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.021367083275821815, https://leetcode.com/problems/two-sum 3 | 76,Minimum Window Substring,34.6%,Hard,0.01693759130600622, https://leetcode.com/problems/minimum-window-substring 4 | 121,Best Time to Buy and Sell Stock,50.5%,Easy,0.00846879565300311, https://leetcode.com/problems/best-time-to-buy-and-sell-stock 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/opendoor_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 150,Evaluate Reverse Polish Notation,36.3%,Medium,0.042316160556566985, https://leetcode.com/problems/evaluate-reverse-polish-notation 3 | 289,Game of Life,54.5%,Medium,0.02542431776514386, https://leetcode.com/problems/game-of-life 4 | 12,Integer to Roman,55.1%,Medium,0.008532474973720734, https://leetcode.com/problems/integer-to-roman 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/opendoor_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 289,Game of Life,54.5%,Medium,0.4018470204215072, https://leetcode.com/problems/game-of-life 3 | 150,Evaluate Reverse Polish Notation,36.3%,Medium,0.20518974769761397, https://leetcode.com/problems/evaluate-reverse-polish-notation 4 | 12,Integer to Roman,55.1%,Medium,0.008532474973720734, https://leetcode.com/problems/integer-to-roman 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/palantir-technologies_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 393,UTF-8 Validation,37.5%,Medium,1.0286574847877104, https://leetcode.com/problems/utf-8-validation 3 | 539,Minimum Time Difference,51.5%,Medium,0.5160651567106544, https://leetcode.com/problems/minimum-time-difference 4 | 56,Merge Intervals,39.3%,Medium,0.0034728286335985107, https://leetcode.com/problems/merge-intervals 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/reddit_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 289,Game of Life,54.5%,Medium,0.10919010790150303, https://leetcode.com/problems/game-of-life 3 | 314,Binary Tree Vertical Order Traversal,45.3%,Medium,0.07017345555905126, https://leetcode.com/problems/binary-tree-vertical-order-traversal 4 | 706,Design HashMap,61.3%,Easy,0.039016652342451774, https://leetcode.com/problems/design-hashmap 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/tripadvisor_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1213,Intersection of Three Sorted Arrays,78.9%,Easy,0.007265965340350701, https://leetcode.com/problems/intersection-of-three-sorted-arrays 3 | 146,LRU Cache,33.2%,Medium,0.004370636328108912, https://leetcode.com/problems/lru-cache 4 | 70,Climbing Stairs,47.8%,Easy,0.0014753073158671238, https://leetcode.com/problems/climbing-stairs 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/deutsche-bank_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 76,Minimum Window Substring,34.6%,Hard,0.0034272505257178826, https://leetcode.com/problems/minimum-window-substring 3 | 121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0021239321954525975, https://leetcode.com/problems/best-time-to-buy-and-sell-stock 4 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/ponyai_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 291,Word Pattern II,43.4%,Hard,0.23430064095771766, https://leetcode.com/problems/word-pattern-ii 3 | 786,K-th Smallest Prime Fraction,41.0%,Hard,0.12438371968773553, https://leetcode.com/problems/k-th-smallest-prime-fraction 4 | 301,Remove Invalid Parentheses,43.3%,Hard,0.01446679841775339, https://leetcode.com/problems/remove-invalid-parentheses 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zoho_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 15,3Sum,26.8%,Medium,0.001153769900788164, https://leetcode.com/problems/3sum 3 | 2,Add Two Numbers,33.9%,Medium,0.0006433776804954862, https://leetcode.com/problems/add-two-numbers 4 | 3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0005103922202926777, https://leetcode.com/problems/longest-substring-without-repeating-characters 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/karat_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 811,Subdomain Visit Count,69.9%,Easy,0.2863511062719155, https://leetcode.com/problems/subdomain-visit-count 3 | 224,Basic Calculator,36.8%,Hard,0.17452286430813568, https://leetcode.com/problems/basic-calculator 4 | 718,Maximum Length of Repeated Subarray,49.4%,Medium,0.06269462234435588, https://leetcode.com/problems/maximum-length-of-repeated-subarray 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/pinterest_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 759,Employee Free Time,66.3%,Hard,0.046479902236053035, https://leetcode.com/problems/employee-free-time 3 | 362,Design Hit Counter,63.7%,Medium,0.025382073271417165, https://leetcode.com/problems/design-hit-counter 4 | 698,Partition to K Equal Sum Subsets,45.0%,Medium,0.02109782896463587, https://leetcode.com/problems/partition-to-k-equal-sum-subsets 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/tencent_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1143,Longest Common Subsequence,58.4%,Medium,0.008271645303004716, https://leetcode.com/problems/longest-common-subsequence 3 | 543,Diameter of Binary Tree,48.4%,Easy,0.005305755914149804, https://leetcode.com/problems/diameter-of-binary-tree 4 | 206,Reverse Linked List,62.5%,Easy,0.0023398665252948926, https://leetcode.com/problems/reverse-linked-list 5 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/02~数组/02.00.md: -------------------------------------------------------------------------------- 1 | ##本章导读 2 | 笔试和面试中,除了字符串,另一类出现频率极高的问题便是与数组相关的问题。在阅读完第1章和本第二章后,读者会慢慢了解到解决面试编程题的有几种常用思路。首先一般考虑“万能的”暴力穷举(递归、回溯),如求n个数的全排列或八皇后(N皇后问题)。但因为穷举时间复杂度通常过高,所以需要考虑更好的方法,如分治法(通过分而治之,然后归并),以及空间换时间(如活用哈希表)。 3 | 4 | 此外,选择合适的数据结构可以显著提升效率,如寻找最小的k个数中,用堆代替数组。 5 | 6 | 再有,如果题目允许排序,则可以考虑排序。比如,寻找和为定值的两个数中,先排序,然后用前后两个指针往中间扫。而如果如果已经排好序了(如杨氏矩阵查找中),则想想有无必要二分。但是,如果题目不允许排序呢?这个时候,我们可以考虑不改变数列顺序的贪心算法(如最小生成树Prim、Kruskal及最短路dijkstra),或动态规划(如 01背包问题,每一步都在决策)。 7 | 8 | 最后,注意细节处理,不要忽略边界条件,如字符串转换成整数。 9 | -------------------------------------------------------------------------------- /02~数据结构/简单数论/科学计算.md: -------------------------------------------------------------------------------- 1 | # 科学计算 2 | 3 | # 进制转换 4 | 5 | 假设在 n 进制下,等式 240\*12=2880 成立,n 值是: 6 | 7 | 假设为 n 进值则 [2*(n^2)+4*(n^1)+0] - [1*n+2]=2*(n^3)+8*(n^2)+8\*(n^1) 8 | 9 | 化简后居然为很等式,n 为任一值 10 | 题目中可以看出,如果用 10 进制代入时,等号左右两边是相等的。因为 10 进制相等的两个数转化为任意进制都会相等,所以答案是多个。 11 | 12 | # Links 13 | 14 | - [计算平方根的算法](http://www.cnblogs.com/xkfz007/archive/2012/05/15/2502348.html) 15 | 16 | - [Wiki-Methods of computing square roots](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series) 17 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/ixl_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 691,Stickers to Spell Word,42.9%,Hard,0.024858702401805627, https://leetcode.com/problems/stickers-to-spell-word 3 | 166,Fraction to Recurring Decimal,21.6%,Medium,0.014594325356283945, https://leetcode.com/problems/fraction-to-recurring-decimal 4 | 234,Palindrome Linked List,39.3%,Easy,0.0043299483107622555, https://leetcode.com/problems/palindrome-linked-list 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/appdynamics_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 346,Moving Average from Data Stream,70.9%,Easy,0.019707237852649603, https://leetcode.com/problems/moving-average-from-data-stream 3 | 221,Maximal Square,37.7%,Medium,0.00988638798855515, https://leetcode.com/problems/maximal-square 4 | 380,Insert Delete GetRandom O(1),47.5%,Medium,0.009820849864094454, https://leetcode.com/problems/insert-delete-getrandom-o1 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/citrix_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1010,Pairs of Songs With Total Durations Divisible by 60,47.4%,Easy,0.0164545776925131, https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 3 | 206,Reverse Linked List,62.5%,Easy,0.009326794511974934, https://leetcode.com/problems/reverse-linked-list 4 | 15,3Sum,26.8%,Medium,0.0021990113314367685, https://leetcode.com/problems/3sum 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/coupang_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 759,Employee Free Time,66.3%,Hard,0.031061089311940182, https://leetcode.com/problems/employee-free-time 3 | 1296,Divide Array in Sets of K Consecutive Numbers,53.8%,Medium,0.016351057660617355, https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers 4 | 79,Word Search,35.6%,Medium,0.0016410260092945288, https://leetcode.com/problems/word-search 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/american-express_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1201,Ugly Number III,25.9%,Medium,0.2586674025861649, https://leetcode.com/problems/ugly-number-iii 3 | 1224,Maximum Equal Frequency,33.5%,Hard,0, https://leetcode.com/problems/maximum-equal-frequency 4 | 1521,Find a Value of a Mysterious Function Closest to Target,43.2%,Hard,0, https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target 5 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/python/3.1:二分查找实现.py: -------------------------------------------------------------------------------- 1 | def binary_search(lst, n): 2 | low, high = 0, len(lst) - 1 3 | while low <= high: 4 | mid = (low + high) / 2 5 | if lst[mid] > n: 6 | high = mid - 1 7 | elif lst[mid] < n: 8 | low = mid + 1 9 | else: 10 | return mid 11 | return -1 12 | 13 | 14 | if __name__ == '__main__': 15 | a = [1, 3, 5, 7, 9] 16 | assert(binary_search(a, 3) == 1) 17 | assert(binary_search(a, 4) == -1) 18 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/asana_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 238,Product of Array Except Self,60.1%,Medium,0.04853298095508739, https://leetcode.com/problems/product-of-array-except-self 3 | 98,Validate Binary Search Tree,27.8%,Medium,0.030442797394926606, https://leetcode.com/problems/validate-binary-search-tree 4 | 973,K Closest Points to Origin,63.8%,Medium,0.012352613834765824, https://leetcode.com/problems/k-closest-points-to-origin 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/hbo_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 722,Remove Comments,34.6%,Medium,0.018941093796349166, https://leetcode.com/problems/remove-comments 3 | 198,House Robber,42.0%,Easy,0.01177072346770526, https://leetcode.com/problems/house-robber 4 | 146,LRU Cache,33.2%,Medium,0.004600353139061353, https://leetcode.com/problems/lru-cache 5 | 139,Word Break,40.1%,Medium,0.003894465052690167, https://leetcode.com/problems/word-break 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/hbo_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 722,Remove Comments,34.6%,Medium,0.05632078951191108, https://leetcode.com/problems/remove-comments 3 | 198,House Robber,42.0%,Easy,0.033320991026093004, https://leetcode.com/problems/house-robber 4 | 146,LRU Cache,33.2%,Medium,0.010321192540274932, https://leetcode.com/problems/lru-cache 5 | 139,Word Break,40.1%,Medium,0.003894465052690167, https://leetcode.com/problems/word-break 6 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/js/1.1:左旋转字符串/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Tests 6 | 7 | 8 | 9 |
10 |
11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/de-shaw_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1358,Number of Substrings Containing All Three Characters,58.2%,Medium,0.2856959744801515, https://leetcode.com/problems/number-of-substrings-containing-all-three-characters 3 | 1122,Relative Sort Array,67.7%,Easy,0, https://leetcode.com/problems/relative-sort-array 4 | 1262,Greatest Sum Divisible by Three,47.6%,Medium,0, https://leetcode.com/problems/greatest-sum-divisible-by-three 5 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/js/1.2:字符串是否包含问题/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Tests 6 | 7 | 8 | 9 |
10 |
11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/js/2.4:寻找和为定值的两个数/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Tests 6 | 7 | 8 | 9 |
10 |
11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /01~算法基础/算法思维/回溯法.md: -------------------------------------------------------------------------------- 1 | # 回溯法 Recursive search 2 | 3 | 回溯法也叫试探法,试探法的处事方式比较委婉,它先暂时放弃关于问题规模大小的限制,并将问题的候选解按某种顺序逐一进行枚举和检验。当发现当前候选解不可能是正确的解时,就选择下一个候选解。如果当前候选解除了不满足问题规模要求外能够满足所有其他要求时,则继续扩大当前候选解的规模,并继续试探。如果当前候选解满足包括问题规模在内的所有要求时,该候选解就是问题的一个解。在试探算法中,放弃当前候选解,并继续寻找下一个候选解的过程称为回溯。扩大当前候选解的规模,并继续试探的过程称为向前试探。 4 | 5 | 使用试探算法解题的基本步骤如下所示。 6 | 7 | - 针对所给问题,定义问题的解空间。 8 | - 确定易于搜索的解空间结构。 9 | - 以深度优先方式搜索解空间,并在搜索过程中用剪枝函数避免无效搜索。 10 | 11 | 试探法为了求得问题的正确解,会先委婉地试探某一种可能的情况。在进行试探的过程中,一旦发现原来选择的假设情况是不正确的,立即会自觉地退回一步重新选择,然后继续向前试探,如此这般反复进行,直至得到解或证明无解时才死心。 12 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/.gitignore: -------------------------------------------------------------------------------- 1 | # Node rules: 2 | ## Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 3 | .grunt 4 | 5 | ## Dependency directory 6 | ## Commenting this out is preferred by some people, see 7 | ## https://docs.npmjs.com/misc/faq#should-i-check-my-node_modules-folder-into-git 8 | node_modules 9 | 10 | # Book build output 11 | _book 12 | 13 | # eBook build output 14 | *.epub 15 | *.mobi 16 | *.pdf 17 | \.idea/ 18 | 19 | *.iml 20 | 21 | src/javaSortTest/target/ 22 | -------------------------------------------------------------------------------- /03~排序/简单排序/选择排序.md: -------------------------------------------------------------------------------- 1 | # 选择排序 2 | 3 | ## Complexity: 算法复杂度 4 | 5 | ### 稳定性 6 | 7 | 选择排序是给每个位置选择当前元素最小的,比如给第一个位置选择最小的,在剩余元素里面给第二个元素选择第二小的,依次类推,直到第 n - 1 个元素,第 n 个元素不用选择了,因为只剩下它一个最大的元素了。那么,在一趟选择,如果当前元素比一个元素小,而该小的元素又出现在一个和当前元素相等的元素后面,那么交换后稳定性就被破坏了。比较拗口,举个例子,序列 5 8 5 2 9,我们知道第一遍选择第 1 个元素 5 会和 2 交换,那么原序列中 2 个 5 的相对前后顺序就被破坏了,所以选择排序不是一个稳定的排序算法。 8 | 9 | 排序算法的稳定性意义在于其能够避免在大数据情况下过多的数据交换,并且能保证如果是在多入口排序情况下的较好的一致性体验,譬如在对 Album 进行排序时,可能先根据 Track Number 进行排序,然后根据 Album Name 进行排序,如果是稳定的算法,当我们以 Album Name 进行排序的时候,就能够保留 Track Number 的有序性。 10 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/hrt_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1323,Maximum 69 Number,77.9%,Easy,0.01658412801553527, https://leetcode.com/problems/maximum-69-number 3 | 1317,Convert Integer to the Sum of Two No-Zero Integers,56.8%,Easy,0, https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers 4 | 1342,Number of Steps to Reduce a Number to Zero,86.3%,Easy,0, https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero 5 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/dataminr_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 57,Insert Interval,33.5%,Hard,0.05771586881832742, https://leetcode.com/problems/insert-interval 3 | 56,Merge Intervals,39.3%,Medium,0.030829638084076787, https://leetcode.com/problems/merge-intervals 4 | 42,Trapping Rain Water,48.9%,Hard,0.02688623073425064, https://leetcode.com/problems/trapping-rain-water 5 | 885,Spiral Matrix III,69.4%,Medium,0, https://leetcode.com/problems/spiral-matrix-iii 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/postmates_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1190,Reverse Substrings Between Each Pair of Parentheses,61.5%,Medium,0.05070219201418402, https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses 3 | 301,Remove Invalid Parentheses,43.3%,Hard,0.03226086221822144, https://leetcode.com/problems/remove-invalid-parentheses 4 | 56,Merge Intervals,39.3%,Medium,0.013819532422258866, https://leetcode.com/problems/merge-intervals 5 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/python/6.6:跳台阶.py: -------------------------------------------------------------------------------- 1 | def fib(n): 2 | a, b, p, q = 1, 0, 0, 1 3 | while n != 0: 4 | if n % 2 == 0: 5 | p, q = p * p + q * q, 2 * p * q + q * q 6 | n = n / 2 7 | else: 8 | a, b = b * q + a * q + a * p, b * p + a * q 9 | n -= 1 10 | return b 11 | 12 | # A simple version by @sfdye 13 | def fib2(n): 14 | a = 0 15 | b = 1 16 | for i in xrange(n): 17 | a, b = b, a+b 18 | return a 19 | 20 | print fib(10) 21 | print fib2(10) -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/python/6.8:第一个只出现一次等问题.py: -------------------------------------------------------------------------------- 1 | def find_first_unique_char(string): 2 | if not string: 3 | return None 4 | chars = {} 5 | for s in string: 6 | if s in chars: 7 | chars[s] += 1 8 | else: 9 | chars[s] = 1 10 | for s in string: 11 | if chars[s] == 1: 12 | return s 13 | 14 | if __name__ == '__main__': 15 | print find_first_unique_char('abababcababdddee') 16 | print find_first_unique_char('') 17 | print find_first_unique_char(None) 18 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/epic-systems_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 306,Additive Number,29.4%,Medium,0.02172297461494173, https://leetcode.com/problems/additive-number 3 | 54,Spiral Matrix,34.1%,Medium,0.014776167707688753, https://leetcode.com/problems/spiral-matrix 4 | 38,Count and Say,44.6%,Easy,0.007829360800435779, https://leetcode.com/problems/count-and-say 5 | 20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/netease_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 46,Permutations,63.5%,Medium,0.003663569603920762, https://leetcode.com/problems/permutations 3 | 33,Search in Rotated Sorted Array,34.5%,Medium,0.0027795573227129993, https://leetcode.com/problems/search-in-rotated-sorted-array 4 | 7,Reverse Integer,25.8%,Easy,0.0017826905514433007, https://leetcode.com/problems/reverse-integer 5 | 1,Two Sum,45.6%,Easy,0.000785823780173602, https://leetcode.com/problems/two-sum 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/riot-games_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 29,Divide Two Integers,16.4%,Medium,0.14250148324930875, https://leetcode.com/problems/divide-two-integers 3 | 495,Teemo Attacking,53.6%,Medium,0.08934510033584994, https://leetcode.com/problems/teemo-attacking 4 | 20,Valid Parentheses,39.0%,Easy,0.03618871742239114, https://leetcode.com/problems/valid-parentheses 5 | 37,Sudoku Solver,43.6%,Hard,0.01821543989134118, https://leetcode.com/problems/sudoku-solver 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/liveramp_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 529,Minesweeper,59.1%,Medium,0.018556866269112182, https://leetcode.com/problems/minesweeper 3 | 785,Is Graph Bipartite?,47.5%,Medium,0.010661081786113668, https://leetcode.com/problems/is-graph-bipartite 4 | 200,Number of Islands,46.8%,Medium,0.002765297303115152, https://leetcode.com/problems/number-of-islands 5 | 20,Valid Parentheses,39.0%,Easy,0.002197682330605871, https://leetcode.com/problems/valid-parentheses 6 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/scheme/chapter25.scm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/guile -s 2 | !# 3 | (define (binary-search lst val) 4 | (define (helper left right) 5 | (if (> left right) (display "no value") 6 | (let* ((idx (quotient (+ left right 1) 2)) 7 | (mid (list-ref lst idx))) 8 | (cond ((= mid val) (display idx)) 9 | ((> mid val) (helper left (- idx 1))) 10 | ((< mid val) (helper (+ idx 1) right)))))) 11 | (helper 0 (- (length lst) 1))) 12 | 13 | (binary-search (list 1 3 5 7 9 15 19 24 36 ) 5) 14 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/twilio_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 974,Subarray Sums Divisible by K,48.9%,Medium,0.13980177259160728, https://leetcode.com/problems/subarray-sums-divisible-by-k 3 | 935,Knight Dialer,45.2%,Medium,0.09737416402517636, https://leetcode.com/problems/knight-dialer 4 | 146,LRU Cache,33.2%,Medium,0.054946555458745445, https://leetcode.com/problems/lru-cache 5 | 68,Text Justification,27.7%,Hard,0.0276451606661453, https://leetcode.com/problems/text-justification 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zoho_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 2,Add Two Numbers,33.9%,Medium,0.004573814287643114, https://leetcode.com/problems/add-two-numbers 3 | 3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0040444464550240785, https://leetcode.com/problems/longest-substring-without-repeating-characters 4 | 15,3Sum,26.8%,Medium,0.0021990113314367685, https://leetcode.com/problems/3sum 5 | 1,Two Sum,45.6%,Easy,0.00184543512358731, https://leetcode.com/problems/two-sum 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/zulily_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1138,Alphabet Board Path,48.4%,Medium,0.033697184154274, https://leetcode.com/problems/alphabet-board-path 3 | 56,Merge Intervals,39.3%,Medium,0.02150990613527447, https://leetcode.com/problems/merge-intervals 4 | 242,Valid Anagram,56.9%,Easy,0.009322628116274939, https://leetcode.com/problems/valid-anagram 5 | 4,Median of Two Sorted Arrays,29.6%,Hard,0.003900160950094767, https://leetcode.com/problems/median-of-two-sorted-arrays 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/factset_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 168,Excel Sheet Column Title,31.1%,Easy,0.11466839631244033, https://leetcode.com/problems/excel-sheet-column-title 3 | 881,Boats to Save People,46.8%,Medium,0.06293179370246599, https://leetcode.com/problems/boats-to-save-people 4 | 171,Excel Sheet Column Number,55.9%,Easy,0.011195191092491645, https://leetcode.com/problems/excel-sheet-column-number 5 | 1,Two Sum,45.6%,Easy,0.00184543512358731, https://leetcode.com/problems/two-sum 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/box_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 191,Number of 1 Bits,49.8%,Easy,0.0973962103257407, https://leetcode.com/problems/number-of-1-bits 3 | 68,Text Justification,27.7%,Hard,0.06116036187169583, https://leetcode.com/problems/text-justification 4 | 965,Univalued Binary Tree,67.7%,Easy,0.04151887834779356, https://leetcode.com/problems/univalued-binary-tree 5 | 250,Count Univalue Subtrees,52.0%,Medium,0.036235848454044865, https://leetcode.com/problems/count-univalue-subtrees 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/evernote_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 202,Happy Number,50.4%,Easy,0.015405898638419502, https://leetcode.com/problems/happy-number 3 | 12,Integer to Roman,55.1%,Medium,0.009668167531572024, https://leetcode.com/problems/integer-to-roman 4 | 238,Product of Array Except Self,60.1%,Medium,0.003930436424724545, https://leetcode.com/problems/product-of-array-except-self 5 | 200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/evernote_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 12,Integer to Roman,55.1%,Medium,0.042897467016516824, https://leetcode.com/problems/integer-to-roman 3 | 202,Happy Number,50.4%,Easy,0.029263682088695783, https://leetcode.com/problems/happy-number 4 | 238,Product of Array Except Self,60.1%,Medium,0.015629897160874744, https://leetcode.com/problems/product-of-array-except-self 5 | 200,Number of Islands,46.8%,Medium,0.011509262420590827, https://leetcode.com/problems/number-of-islands 6 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/cpp/chapter04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | char *mystrcpy(char* dest, const char *src) 6 | { 7 | assert(dest != NULL && src != NULL); 8 | assert(dest < src || strlen(src) < (unsigned int)(dest - src)); 9 | if (src == dest) 10 | return dest; 11 | char *ret = dest; 12 | while('\0' != (*dest++ = *src++)) 13 | ; 14 | return ret; 15 | } 16 | 17 | int main() 18 | { 19 | char dest[1024]; 20 | char src[] = "abcdef"; 21 | mystrcpy(dest, src); 22 | printf("%s\n", dest); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/houzz_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 227,Basic Calculator II,36.9%,Medium,0.028031313778810817, https://leetcode.com/problems/basic-calculator-ii 3 | 721,Accounts Merge,48.8%,Medium,0.01888630262874805, https://leetcode.com/problems/accounts-merge 4 | 304,Range Sum Query 2D - Immutable,38.6%,Medium,0.013913267916985026, https://leetcode.com/problems/range-sum-query-2d-immutable 5 | 43,Multiply Strings,33.9%,Medium,0.009145011150062768, https://leetcode.com/problems/multiply-strings 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/two-sigma_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1048,Longest String Chain,54.7%,Medium,0.2556185513689736, https://leetcode.com/problems/longest-string-chain 3 | 547,Friend Circles,58.6%,Medium,0.14039031404424082, https://leetcode.com/problems/friend-circles 4 | 123,Best Time to Buy and Sell Stock III,37.5%,Hard,0.02516207671950806, https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii 5 | 146,LRU Cache,33.2%,Medium,0.010321192540274932, https://leetcode.com/problems/lru-cache 6 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/ruby/chapter06.amicableNumber.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # -*- coding: UTF-8 -*- 3 | 4 | def amicable_number max 5 | half = max / 2 6 | sum = Array.new(max){1} 7 | (2...half).each do|i| 8 | (i + i).step(max + 1, i)do|j| 9 | sum[j] += i unless sum[j].nil? 10 | end 11 | end 12 | ans = [] 13 | sum.each_with_index do | s, i| 14 | ans.push([i, s]) if s > i && s <= max && sum[s] == i 15 | end 16 | ans 17 | end 18 | 19 | 20 | 21 | if __FILE__ == $0 22 | amicable_number( 500000 ).each{|e| 23 | p "%d %d" % e 24 | } 25 | end 26 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/karat_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 811,Subdomain Visit Count,69.9%,Easy,0.3987888387462064, https://leetcode.com/problems/subdomain-visit-count 3 | 224,Basic Calculator,36.8%,Hard,0.23074173054528113, https://leetcode.com/problems/basic-calculator 4 | 718,Maximum Length of Repeated Subarray,49.4%,Medium,0.06269462234435588, https://leetcode.com/problems/maximum-length-of-repeated-subarray 5 | 85,Maximal Rectangle,37.7%,Hard,0.013333530869465187, https://leetcode.com/problems/maximal-rectangle 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/karat_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 811,Subdomain Visit Count,69.9%,Easy,0.3987888387462064, https://leetcode.com/problems/subdomain-visit-count 3 | 224,Basic Calculator,36.8%,Hard,0.23074173054528113, https://leetcode.com/problems/basic-calculator 4 | 718,Maximum Length of Repeated Subarray,49.4%,Medium,0.06269462234435588, https://leetcode.com/problems/maximum-length-of-repeated-subarray 5 | 85,Maximal Rectangle,37.7%,Hard,0.013333530869465187, https://leetcode.com/problems/maximal-rectangle 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/karat_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 811,Subdomain Visit Count,69.9%,Easy,1.0710122881269506, https://leetcode.com/problems/subdomain-visit-count 3 | 224,Basic Calculator,36.8%,Hard,0.5668534552356532, https://leetcode.com/problems/basic-calculator 4 | 718,Maximum Length of Repeated Subarray,49.4%,Medium,0.06269462234435588, https://leetcode.com/problems/maximum-length-of-repeated-subarray 5 | 85,Maximal Rectangle,37.7%,Hard,0.013333530869465187, https://leetcode.com/problems/maximal-rectangle 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/ponyai_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 291,Word Pattern II,43.4%,Hard,0.4894087826129644, https://leetcode.com/problems/word-pattern-ii 3 | 786,K-th Smallest Prime Fraction,41.0%,Hard,0.2608348224155929, https://leetcode.com/problems/k-th-smallest-prime-fraction 4 | 301,Remove Invalid Parentheses,43.3%,Hard,0.03226086221822144, https://leetcode.com/problems/remove-invalid-parentheses 5 | 1235,Maximum Profit in Job Scheduling,44.0%,Hard,0, https://leetcode.com/problems/maximum-profit-in-job-scheduling 6 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/works-applications_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 179,Largest Number,28.8%,Medium,0.07393612143915611, https://leetcode.com/problems/largest-number 3 | 1,Two Sum,45.6%,Easy,0.03943855709894935, https://leetcode.com/problems/two-sum 4 | 15,3Sum,26.8%,Medium,0.004940992758742591, https://leetcode.com/problems/3sum 5 | 629,K Inverse Pairs Array,31.1%,Hard,0, https://leetcode.com/problems/k-inverse-pairs-array 6 | 630,Course Schedule III,33.5%,Hard,0, https://leetcode.com/problems/course-schedule-iii 7 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/5.4:交替字符串.c: -------------------------------------------------------------------------------- 1 | bool isInterleave(string s1, string s2, string s3) 2 | { 3 | 4 | int len1 = s1.size(), len2 = s2.size(), len3 = s3.size(); 5 | if (len3 != len1 + len2) { 6 | return false; 7 | } 8 | vector > dp; 9 | dp.resize(len1 + 1); 10 | for (int i = 0; i <= len1; ++i) { 11 | dp[i].resize(len2 + 1, false); 12 | for (int j = 0; j <= len2; ++j) { 13 | dp[i][j] = ((i == 0) && (j == 0)) || (i && dp[i - 1][j] && (s1[i - 1] == s3[i + j - 1])) || (j && dp[i][j - 1] && (s2[j - 1] == s3[i + j - 1])); 14 | } 15 | } 16 | return dp[len1][len2]; 17 | } 18 | -------------------------------------------------------------------------------- /02~数据结构/简单数论/位运算.md: -------------------------------------------------------------------------------- 1 | # 位运算 2 | 3 | ```c 4 | int Add(int x, int y) 5 | { 6 | // Iterate till there is no carry 7 | while (y != 0) 8 | { 9 | // carry now contains common set bits of x and y 10 | int carry = x & y; 11 | 12 | // Sum of bits of x and y where at least one of the bits is not set 13 | x = x ^ y; 14 | 15 | // Carry is shifted by one so that adding it to x gives the required sum 16 | y = carry << 1; 17 | } 18 | return x; 19 | } 20 | 21 | 22 | int Add(int x, int y) 23 | { 24 | if (y == 0) 25 | return x; 26 | else 27 | return Add( x ^ y, (x & y) << 1); 28 | } 29 | ``` 30 | -------------------------------------------------------------------------------- /03~排序/简单排序/README.md: -------------------------------------------------------------------------------- 1 | # Sorting 2 | 3 | ![](http://upload-images.jianshu.io/upload_images/273973-19cf4a1e58b6ebaf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 4 | 5 | ![](http://blog.chinaunix.net/attachment/201201/18/21457204_1326898064RUxx.jpg) 6 | 7 | n 个数值选出最大 m 个数(3 len(array): 20 | return value 21 | 22 | 23 | if __name__ == '__main__': 24 | print more_than_half_number([0, 3, 1, 3, 2, 3, 4, 3, 3, 3]) 25 | -------------------------------------------------------------------------------- /02~数据结构/字符串/模式匹配/多模式匹配.md: -------------------------------------------------------------------------------- 1 | # Aho-Corasick 算法 2 | 3 | Aho-Corasick 算法在 1975 年产生于贝尔实验室,是著名的多模匹配算法之一。一个常见的例子就是给出 n 个单词,再给出一段包含 m 个字符的文章,让你找出有多少个单词在文章里出现过。KMP 中我们用两个指针 i 和 j 分别表示,A[i-j+ 1..i] 与 B[1..j] 完全相等。也就是说,i 是不断增加的,随着 i 的增加 j 相应地变化,且 j 满足以 A[i] 结尾的长度为 j 的字符串正好匹配 B 串的前 j 个字符,当 A[i+1]≠B[j+1],KMP 的策略是调整 j 的位置(减小 j 值)使得 A[i-j+1..i] 与 B[1..j] 保持匹配且新的 B[j+1] 恰好与 A[i+1] 匹配,而 next 函数恰恰记录了这个 j 应该调整到的位置。同样 AC 自动机的失败指针具有同样的功能,自动机本身是计算理论的一个概念;其实是一张“图”,每个点是一个“状态”,而边则是状态之间的转移,根据条件能指导从一个状态走向另一个状态。很多字符串匹配算法都是基于自动机模型的,比如被广泛使用的正则表达式。AC 自动机算法算是比较简单直观的字符串匹配自动机,它其实就是在一颗 Trie 树上建一些失配指针,当失配时只要顺着失配指针走,就能避免一些重复的计算。比如对于字符串 antibody 和 tide,如果第一个串匹配到第 5 个字符(b)失配了可以直接走入第二个串的第 3 个字符(d)进行匹配,因为前面的“ti”是公共的,如果能匹配到第一个串的第 5 个字符,那么前面两个肯定是 ti。 4 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/sap_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1349,Maximum Students Taking Exam,42.0%,Hard,0.07966246608975645, https://leetcode.com/problems/maximum-students-taking-exam 3 | 1283,Find the Smallest Divisor Given a Threshold,47.6%,Medium,0.047798823737776906, https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold 4 | 509,Fibonacci Number,67.2%,Easy,0.01593518138579736, https://leetcode.com/problems/fibonacci-number 5 | 322,Coin Change,35.5%,Medium,0.004029826126500844, https://leetcode.com/problems/coin-change 6 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 7 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/ibm_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 134,Gas Station,38.5%,Medium,0.012001361253146894, https://leetcode.com/problems/gas-station 3 | 259,3Sum Smaller,47.6%,Medium,0.008471177005944745, https://leetcode.com/problems/3sum-smaller 4 | 15,3Sum,26.8%,Medium,0.004940992758742591, https://leetcode.com/problems/3sum 5 | 88,Merge Sorted Array,39.4%,Easy,0.0030102370714243072, https://leetcode.com/problems/merge-sorted-array 6 | 20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses 7 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 8 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/03~树/03.00.md: -------------------------------------------------------------------------------- 1 | ## 本章导读 2 | 3 | 想要更好地理解红黑树,可以先理解二叉查找树和2-3树。为何呢?首先,二叉查找树中的结点是2-结点(一个键两条链),引入3-结点(两个键三条链),即成2-3树;然后将2-3树中3-结点分解,即成红黑树,故结合二叉查找树易查找和2-3树易插入的特点,便成了红黑二叉查找树,简称红黑树。 4 | 5 | 进一步而言,理解了2-3树,也就理解了B树、B+树、B*树,因为2-3树就是一棵3阶的B树,而一颗3阶的B树各个结点关键字数满足1-2,故当结点关键字数多于2时则达到饱和,此时需要分裂结点,而结点关键字数少于1时则从兄弟结点“借”关键字补充。 6 | 7 | 但为何有了红黑树,还要发明B树呢?原因是,当计算机要处理的数据量一大,便无法一次性装入内存进行处理,于此,计算机会把大部分备用的数据存在磁盘中,有需要的时候,就从磁盘中调取数据到在内存中处理,如果处理时修改了数据,则再次将数据写入磁盘,如此导致了不断的磁盘IO读写,而树的高度越高,查找文件所需要的磁盘IO读写次数越多,所以为了减少磁盘的IO读写,要想办法进一步降低树的高度。 8 | 因此,具有多个孩子的B树便应运而生,因为B树每一个结点可以有几个到几千个孩子,使得在结点数目一定的情况下,树的高度会大大降低,从而有效减少磁盘IO读写消耗。 9 | 10 | 此外,无论是B树,还是B+树、B*树,由于根或者树的上面几层被反复查询,所以树上层几块的数据可以存在内存中。换言之,B树、B+树、B*树的根结点和部分顶层数据存在内存中,大部分下层数据存在磁盘上。 11 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/06~海量数据处理/06.00.md: -------------------------------------------------------------------------------- 1 | ## 本章导读 2 | 3 | 所谓海量数据处理,是指基于海量数据的存储、处理、和操作。正因为数据量太大,所以导致要么无法在较短时间内迅速解决,要么无法一次性装入内存。 4 | 5 | 事实上,针对时间问题,可以采用巧妙的算法搭配合适的数据结构(如布隆过滤器、哈希、位图、堆、数据库、倒排索引、Trie 树)来解决;而对于空间问题,可以采取分而治之(哈希映射)的方法,也就是说,把规模大的数据转化为规模小的,从而各个击破。 6 | 7 | 此外,针对常说的单机及集群问题,通俗来讲,单机就是指处理装载数据的机器有限(只要考虑 CPU、内存、和硬盘之间的数据交互),而集群的意思是指机器有多台,适合分布式处理或并行计算,更多考虑节点与节点之间的数据交互。 8 | 9 | 一般说来,处理海量数据问题,有以下十种典型方法: 10 | 11 | - 1.哈希分治; 12 | - 2.simhash 算法; 13 | - 3.外排序; 14 | - 4.MapReduce; 15 | - 5.多层划分; 16 | - 6.位图; 17 | - 7.布隆过滤器; 18 | - 8.Trie 树; 19 | - 9.数据库; 20 | - 10.倒排索引。 21 | 22 | 受理论之限,本章将摒弃绝大部分的细节,只谈方法和模式论,注重用最通俗、最直白的语言阐述相关问题。最后,有一点必须强调的是,全章行文是基于面试题的分析基础之上的,具体实践过程中,还得视具体情况具体分析,且各个场景下需要考虑的细节也远比本章所描述的任何一种解决方案复杂得多。 23 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/4.3:出现次数超过一半的数字.c: -------------------------------------------------------------------------------- 1 | // 4.3 出现次数超过一半.cpp : 定义控制台应用程序的入口点。 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | using namespace std; 7 | 8 | //a代表数组,length代表数组长度 9 | int FindOneNumber(int* a, int length) 10 | { 11 | int candidate = a[0]; 12 | int nTimes, i; 13 | for (i = nTimes = 0; i < length; i++) 14 | { 15 | if (candidate == a[i]) 16 | nTimes++; 17 | else 18 | nTimes--; 19 | if (nTimes == 0) 20 | { 21 | candidate = a[i]; 22 | nTimes = 1; 23 | } 24 | } 25 | return candidate; 26 | } 27 | 28 | int main() 29 | { 30 | int a[10] = { 1, 2, 3, 4, 6, 6, 6, 6, 6 }; 31 | int* n = a; 32 | cout << FindOneNumber(a, 9) << endl; 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/morgan-stanley_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 121,Best Time to Buy and Sell Stock,50.5%,Easy,0.007502371594599209, https://leetcode.com/problems/best-time-to-buy-and-sell-stock 3 | 41,First Missing Positive,32.0%,Hard,0.005444881762408285, https://leetcode.com/problems/first-missing-positive 4 | 160,Intersection of Two Linked Lists,40.6%,Easy,0.003934945881316586, https://leetcode.com/problems/intersection-of-two-linked-lists 5 | 53,Maximum Subarray,46.5%,Easy,0.003902924955778234, https://leetcode.com/problems/maximum-subarray 6 | 1,Two Sum,45.6%,Easy,0.00184543512358731, https://leetcode.com/problems/two-sum 7 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/qualtrics_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 729,My Calendar I,51.8%,Medium,0.01003093468087332, https://leetcode.com/problems/my-calendar-i 3 | 138,Copy List with Random Pointer,36.4%,Medium,0.006191011880825271, https://leetcode.com/problems/copy-list-with-random-pointer 4 | 127,Word Ladder,29.6%,Medium,0.005979091056058075, https://leetcode.com/problems/word-ladder 5 | 139,Word Break,40.1%,Medium,0.003894465052690167, https://leetcode.com/problems/word-break 6 | 103,Binary Tree Zigzag Level Order Traversal,48.3%,Medium,0.003839922800048048, https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal 7 | -------------------------------------------------------------------------------- /02~数据结构/字符串/正则表达式/01.结构与操作符.md: -------------------------------------------------------------------------------- 1 | # 结构与操作符 2 | 3 | ## 元字符 4 | 5 | 元字符是构造正则表达式的一种基本元素。 6 | 7 | 元字符 说明 8 | . 匹配除换行符以外的任意字符 9 | \w 匹配字母或数字或下划线或汉字 10 | \s 匹配任意的空白符 11 | \d 匹配数字 12 | \b 匹配单词的开始或结束 13 | ^ 匹配字符串的开始 14 | \$ 匹配字符串结束 15 | 16 | 正则提供了转义的方式,也就是要把这些元字符、限定符或者关键字转义成普通的字符,做法很简答,就是在要转义的字符前面加个斜杠,也就是\即可。 17 | 18 | ## 重复限定符 19 | 20 | 正则表达式中一些重复限定符,把重复部分用合适的限定符替代,下面我们来看一些限定符: 21 | 22 | 语法 说明 23 | 24 | - 重复零次或更多次 25 | 26 | * 重复一次或更多次 27 | ? 重复零次或一次 28 | {n} 重复 n 次 29 | {n,} 重复 n 次或更多次 30 | {n,m} 重复 n 到 m 次 31 | 32 | ## 分组与条件 33 | 34 | 正则表达式中用小括号 () 来做分组,也就是括号中的内容作为一个整体。 35 | 36 | 正则用符号 | 来表示或,也叫做分支条件,当满足正则里的分支条件的任何一种条件时,都会当成是匹配成功。 37 | 38 | ``` 39 | ^(130|131|132|155|156|185|186|145|176)\d{8}\$ 40 | ``` 41 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/epic-systems_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 306,Additive Number,29.4%,Medium,0.6788194694611859, https://leetcode.com/problems/additive-number 3 | 54,Spiral Matrix,34.1%,Medium,0.42911099324046365, https://leetcode.com/problems/spiral-matrix 4 | 38,Count and Say,44.6%,Easy,0.17940251701974141, https://leetcode.com/problems/count-and-say 5 | 20,Valid Parentheses,39.0%,Easy,0.020517047266669974, https://leetcode.com/problems/valid-parentheses 6 | 728,Self Dividing Numbers,74.3%,Easy,0, https://leetcode.com/problems/self-dividing-numbers 7 | 1215,Stepping Numbers,41.6%,Medium,0, https://leetcode.com/problems/stepping-numbers 8 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/ruby/chapter16.permutation.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # -*- coding: UTF-8 -*- 3 | def permutation_recursive(ar) 4 | return [ar] if ar.length == 1 5 | permutations = [] 6 | ar.each_with_index{|a, i| 7 | arc = ar.clone; arc.delete_at(i) 8 | subpermutations = permutation_recursive(arc) 9 | subpermutations.each{|x| 10 | permutations.push( [a] + x) 11 | } 12 | } 13 | 14 | return permutations 15 | end 16 | 17 | 18 | if __FILE__ == $0 19 | test_cases = [["A", "B", "C"]] 20 | test_cases.each{|tc| 21 | permutations = permutation_recursive(tc) 22 | p "permutation", permutations, permutations.sort == tc.permutation(tc.length).sort 23 | } 24 | 25 | 26 | 27 | end -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/affirm_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 381,Insert Delete GetRandom O(1) - Duplicates allowed,34.1%,Hard,0.10584435094403895, https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed 3 | 380,Insert Delete GetRandom O(1),47.5%,Medium,0.057001980519332376, https://leetcode.com/problems/insert-delete-getrandom-o1 4 | 49,Group Anagrams,56.9%,Medium,0.008159610094625805, https://leetcode.com/problems/group-anagrams 5 | 42,Trapping Rain Water,48.9%,Hard,0.00411947029523883, https://leetcode.com/problems/trapping-rain-water 6 | 322,Coin Change,35.5%,Medium,0.003863246064215582, https://leetcode.com/problems/coin-change 7 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/python/2.4:寻找和为定值的两个数.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding:utf-8 -*- 3 | 4 | def find_sum(array, key): 5 | if len(array) > 0: 6 | array = sorted(array) 7 | start = 0 8 | end = len(array) - 1 9 | while start < end: 10 | result = array[start] + array[end] 11 | if result > key: 12 | end -= 1 13 | elif result < key: 14 | start += 1 15 | else: 16 | return [array[start], array[end]] 17 | return False 18 | 19 | def main(): 20 | array = [4, 2, 1, 7, 11, 15] 21 | key = 15 22 | print find_sum(array, key) 23 | return 24 | 25 | if __name__ == '__main__': 26 | main() 27 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/netease_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1,Two Sum,45.6%,Easy,0.01757418391706516, https://leetcode.com/problems/two-sum 3 | 33,Search in Rotated Sorted Array,34.5%,Medium,0.012342978578758374, https://leetcode.com/problems/search-in-rotated-sorted-array 4 | 7,Reverse Integer,25.8%,Easy,0.007111773240451589, https://leetcode.com/problems/reverse-integer 5 | 46,Permutations,63.5%,Medium,0.003984069014874407, https://leetcode.com/problems/permutations 6 | 664,Strange Printer,40.2%,Hard,0, https://leetcode.com/problems/strange-printer 7 | 826,Most Profit Assigning Work,38.5%,Medium,0, https://leetcode.com/problems/most-profit-assigning-work 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/reddit_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 289,Game of Life,54.5%,Medium,0.14824301157875866, https://leetcode.com/problems/game-of-life 3 | 314,Binary Tree Vertical Order Traversal,45.3%,Medium,0.10758430200165091, https://leetcode.com/problems/binary-tree-vertical-order-traversal 4 | 706,Design HashMap,61.3%,Easy,0.0683442674369718, https://leetcode.com/problems/design-hashmap 5 | 227,Basic Calculator II,36.9%,Medium,0.027685557859864054, https://leetcode.com/problems/basic-calculator-ii 6 | 987,Vertical Order Traversal of a Binary Tree,36.6%,Medium,0.011601058182762062, https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree 7 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/reddit_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 289,Game of Life,54.5%,Medium,0.20761483400383401, https://leetcode.com/problems/game-of-life 3 | 314,Binary Tree Vertical Order Traversal,45.3%,Medium,0.15148600467306356, https://leetcode.com/problems/binary-tree-vertical-order-traversal 4 | 706,Design HashMap,61.3%,Easy,0.10482987091202353, https://leetcode.com/problems/design-hashmap 5 | 227,Basic Calculator II,36.9%,Medium,0.04870104158125306, https://leetcode.com/problems/basic-calculator-ii 6 | 987,Vertical Order Traversal of a Binary Tree,36.6%,Medium,0.011601058182762062, https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree 7 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/06~海量数据处理/06.11.md: -------------------------------------------------------------------------------- 1 | # 倒排索引(Inverted index) 2 | 3 | ## 方法介绍 4 | 5 | 倒排索引是一种索引方法,被用来存储在全文搜索下某个单词在一个文档或者一组文档中的存储位置的映射,常被应用于搜索引擎和关键字查询的问题中。 6 | 7 | 以英文为例,下面是要被索引的文本: 8 | 9 | T0 = "it is what it is" 10 | T1 = "what is it" 11 | T2 = "it is a banana" 12 | 13 | 我们就能得到下面的反向文件索引: 14 | 15 | "a": {2} 16 | "banana": {2} 17 | "is": {0, 1, 2} 18 | "it": {0, 1, 2} 19 | "what": {0, 1} 20 | 21 | 检索的条件"what","is"和"it"将对应集合的交集。 22 | 23 | 正向索引开发出来用来存储每个文档的单词的列表。正向索引的查询往往满足每个文档有序频繁的全文查询和每个单词在校验文档中的验证这样的查询。在正向索引中,文档占据了中心的位置,每个文档指向了一个它所包含的索引项的序列。也就是说文档指向了它包含的那些单词,而反向索引则是单词指向了包含它的文档,很容易看到这个反向的关系。 24 | 25 | ## 问题实例 26 | 27 | **1、文档检索系统,查询那些文件包含了某单词,比如常见的学术论文的关键字搜索** 28 | 29 | **提示**:建倒排索引。 30 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/intuit_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 68,Text Justification,27.7%,Hard,0.15100810299709522, https://leetcode.com/problems/text-justification 3 | 811,Subdomain Visit Count,69.9%,Easy,0.09613042044188254, https://leetcode.com/problems/subdomain-visit-count 4 | 729,My Calendar I,51.8%,Medium,0.06976137056995267, https://leetcode.com/problems/my-calendar-i 5 | 79,Word Search,35.6%,Medium,0.014883688014740005, https://leetcode.com/problems/word-search 6 | 146,LRU Cache,33.2%,Medium,0.004600353139061353, https://leetcode.com/problems/lru-cache 7 | 20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/wish_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 616,Add Bold Tag in String,43.1%,Medium,0.0275898212601313, https://leetcode.com/problems/add-bold-tag-in-string 3 | 314,Binary Tree Vertical Order Traversal,45.3%,Medium,0.018010392274465332, https://leetcode.com/problems/binary-tree-vertical-order-traversal 4 | 153,Find Minimum in Rotated Sorted Array,45.1%,Medium,0.008430963288799368, https://leetcode.com/problems/find-minimum-in-rotated-sorted-array 5 | 207,Course Schedule,43.1%,Medium,0.004964021114211758, https://leetcode.com/problems/course-schedule 6 | 200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands 7 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/pocket-gems_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 740,Delete and Earn,48.6%,Medium,0.3388354652429152, https://leetcode.com/problems/delete-and-earn 3 | 547,Friend Circles,58.6%,Medium,0.3127316472971021, https://leetcode.com/problems/friend-circles 4 | 1010,Pairs of Songs With Total Durations Divisible by 60,47.4%,Easy,0.17202345756942927, https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 5 | 366,Find Leaves of Binary Tree,70.6%,Medium,0.147594083694218, https://leetcode.com/problems/find-leaves-of-binary-tree 6 | 10,Regular Expression Matching,26.8%,Hard,0.006885893966545159, https://leetcode.com/problems/regular-expression-matching 7 | -------------------------------------------------------------------------------- /02~数据结构/线性表/链表/README.md: -------------------------------------------------------------------------------- 1 | # 链表 2 | 3 | 链表是一种通过指针串联在一起的线性结构,每一个节点是又两部分组成,一个是数据域一个是指针域(存放指向下一个节点的指针),最后一个节点的指针域指向 null(空指针的意思)。链接的入口点称为列表的头结点也就是 head。 4 | 5 | ![链表示意](https://pic.imgdb.cn/item/6118e3e35132923bf884f8fa.png) 6 | 7 | 链表主要包含以下几类: 8 | 9 | - 单链表:单链表中的节点只能指向节点的下一个节点。 10 | 11 | - 双链表:每一个节点有两个指针域,一个指向下一个节点,一个指向上一个节点。双链表 既可以向前查询也可以向后查询。 12 | 13 | ![双链表示意图](https://pic.imgdb.cn/item/6118e4c25132923bf8882d9b.jpg) 14 | 15 | - 循环链表: 循环链表,顾名思义,就是链表首尾相连。循环链表可以用来解决约瑟夫环问题。 16 | 17 | ![循环链表](https://pic.imgdb.cn/item/6118e4e15132923bf888a3aa.jpg) 18 | 19 | # Links 20 | 21 | - [A Gentle Introduction to Data Structures: How Linked Lists Work](https://medium.freecodecamp.com/a-gentle-introduction-to-data-structures-how-linked-lists-work-5adc793897dd#.8vgkaayu3) 22 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/nutanix_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 991,Broken Calculator,45.6%,Medium,0.3917108530690627, https://leetcode.com/problems/broken-calculator 3 | 1052,Grumpy Bookstore Owner,55.4%,Medium,0.20881791529768876, https://leetcode.com/problems/grumpy-bookstore-owner 4 | 403,Frog Jump,39.7%,Hard,0.0259249775263148, https://leetcode.com/problems/frog-jump 5 | 55,Jump Game,34.6%,Medium,0.011265609194218986, https://leetcode.com/problems/jump-game 6 | 45,Jump Game II,30.6%,Hard,0.009546611883579968, https://leetcode.com/problems/jump-game-ii 7 | 5,Longest Palindromic Substring,29.5%,Medium,0.002279333142507479, https://leetcode.com/problems/longest-palindromic-substring 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/barclays_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 509,Fibonacci Number,67.2%,Easy,0.03801871583399193, https://leetcode.com/problems/fibonacci-number 3 | 115,Distinct Subsequences,38.3%,Hard,0.027798871362742988, https://leetcode.com/problems/distinct-subsequences 4 | 20,Valid Parentheses,39.0%,Easy,0.020517047266669974, https://leetcode.com/problems/valid-parentheses 5 | 91,Decode Ways,24.7%,Medium,0.013379120336324091, https://leetcode.com/problems/decode-ways 6 | 273,Integer to English Words,27.1%,Hard,0.012081089250339716, https://leetcode.com/problems/integer-to-english-words 7 | 7,Reverse Integer,25.8%,Easy,0.0018612447790907708, https://leetcode.com/problems/reverse-integer 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/barclays_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 115,Distinct Subsequences,38.3%,Hard,0.10259092868139033, https://leetcode.com/problems/distinct-subsequences 3 | 509,Fibonacci Number,67.2%,Easy,0.07958999426900074, https://leetcode.com/problems/fibonacci-number 4 | 273,Integer to English Words,27.1%,Hard,0.06896929475435468, https://leetcode.com/problems/integer-to-english-words 5 | 20,Valid Parentheses,39.0%,Easy,0.0631039942300807, https://leetcode.com/problems/valid-parentheses 6 | 91,Decode Ways,24.7%,Medium,0.03248261950458574, https://leetcode.com/problems/decode-ways 7 | 7,Reverse Integer,25.8%,Easy,0.0018612447790907708, https://leetcode.com/problems/reverse-integer 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/hulu_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 326,Power of Three,42.1%,Easy,0.02907623878526534, https://leetcode.com/problems/power-of-three 3 | 907,Sum of Subarray Minimums,32.3%,Medium,0.02877881426353932, https://leetcode.com/problems/sum-of-subarray-minimums 4 | 394,Decode String,50.0%,Medium,0.01743216716867105, https://leetcode.com/problems/decode-string 5 | 230,Kth Smallest Element in a BST,60.2%,Medium,0.006085520073802784, https://leetcode.com/problems/kth-smallest-element-in-a-bst 6 | 139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break 7 | 49,Group Anagrams,56.9%,Medium,0.0036347154963361594, https://leetcode.com/problems/group-anagrams 8 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['https://paypal.me/hustcc', 'https://atool.vip'] 13 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/asana_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 98,Validate Binary Search Tree,27.8%,Medium,0.15946580717044478, https://leetcode.com/problems/validate-binary-search-tree 3 | 238,Product of Array Except Self,60.1%,Medium,0.14381651020193786, https://leetcode.com/problems/product-of-array-except-self 4 | 973,K Closest Points to Origin,63.8%,Medium,0.0846954809648288, https://leetcode.com/problems/k-closest-points-to-origin 5 | 146,LRU Cache,33.2%,Medium,0.06773642472794494, https://leetcode.com/problems/lru-cache 6 | 50,Pow(x;n),30.3%,Medium,0.008615395490835889, https://leetcode.com/problems/powx-n 7 | 53,Maximum Subarray,46.5%,Easy,0.0020745819379855658, https://leetcode.com/problems/maximum-subarray 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/asana_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 238,Product of Array Except Self,60.1%,Medium,0.14079121889577595, https://leetcode.com/problems/product-of-array-except-self 3 | 146,LRU Cache,33.2%,Medium,0.09466027715846642, https://leetcode.com/problems/lru-cache 4 | 98,Validate Binary Search Tree,27.8%,Medium,0.08515143211698117, https://leetcode.com/problems/validate-binary-search-tree 5 | 973,K Closest Points to Origin,63.8%,Medium,0.05474633722814542, https://leetcode.com/problems/k-closest-points-to-origin 6 | 50,Pow(x;n),30.3%,Medium,0.008615395490835889, https://leetcode.com/problems/powx-n 7 | 53,Maximum Subarray,46.5%,Easy,0.008272628741228982, https://leetcode.com/problems/maximum-subarray 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/blackrock_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 322,Coin Change,35.5%,Medium,0.03257065710568334, https://leetcode.com/problems/coin-change 3 | 12,Integer to Roman,55.1%,Medium,0.018163970627671163, https://leetcode.com/problems/integer-to-roman 4 | 238,Product of Array Except Self,60.1%,Medium,0.003757284149658983, https://leetcode.com/problems/product-of-array-except-self 5 | 200,Number of Islands,46.8%,Medium,0.002765297303115152, https://leetcode.com/problems/number-of-islands 6 | 121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock 7 | 1,Two Sum,45.6%,Easy,0.001767235914611495, https://leetcode.com/problems/two-sum 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/blackrock_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 322,Coin Change,35.5%,Medium,0.04715183980861924, https://leetcode.com/problems/coin-change 3 | 1,Two Sum,45.6%,Easy,0.03267443218434049, https://leetcode.com/problems/two-sum 4 | 121,Best Time to Buy and Sell Stock,50.5%,Easy,0.018197024560061743, https://leetcode.com/problems/best-time-to-buy-and-sell-stock 5 | 12,Integer to Roman,55.1%,Medium,0.018163970627671163, https://leetcode.com/problems/integer-to-roman 6 | 238,Product of Array Except Self,60.1%,Medium,0.014945168886283782, https://leetcode.com/problems/product-of-array-except-self 7 | 200,Number of Islands,46.8%,Medium,0.006211200092640676, https://leetcode.com/problems/number-of-islands 8 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/ruby/chapter07.findMaxSum.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # -*- coding: UTF-8 -*- 3 | 4 | def max_sum(arr) 5 | max, max_sub, sum, sub = arr[0], [arr[0]], 0, [] 6 | arr.each do |x| 7 | if sum >= 0 8 | sum += x; sub.push(x) 9 | else 10 | sum, sub = x, [x] 11 | end 12 | max, max_sub = sum, sub.clone if(max < sum) 13 | end 14 | [max, max_sub] 15 | end 16 | 17 | def max_sum_dp(arr) 18 | sum = Array.new(arr.length){0} 19 | sum[0] = arr[0] 20 | 1.upto(arr.length - 1){|i| 21 | sum[i] = [ arr[i], sum[i-1] + arr[i]].max 22 | } 23 | sum.max 24 | end 25 | 26 | 27 | if __FILE__ == $0 28 | 29 | [ [-1,-2,-3,-4] , [1, -2, 3, 10, -4, 7, 2, -5] ] .each{ |ar| 30 | p ar, max_sum(ar), max_sum_dp(ar) 31 | } 32 | 33 | end 34 | -------------------------------------------------------------------------------- /02~数据结构/树/哈夫曼/README.md: -------------------------------------------------------------------------------- 1 | # 哈夫曼 2 | 3 | 当树中的节点被赋予一个表示某种意义的数值,我们称之为该节点的权。从树的根节点到任意节点的路径长度(经过的边数)与该节点上权值的乘积称为该节点的带权路径长度。树中所有叶节点的带权路径长度之和称为该树的带权路径长度(WPL)。当带权路径长度最小的二叉树被称为哈夫曼树,也成为最优二叉树。 4 | 5 | 哈夫曼树在构造时每次从备选节点中挑出两个权值最小的节点进行构造,每次构造完成后会生成新的节点,将构造的节点从备选节点中删除并将新产生的节点加入到备选节点中。新产生的节点权值为参与构造的两个节点权值之和。举例如下: 6 | 7 | - [](https://images2015.cnblogs.com/blog/872539/201611/872539-20161104194812346-1641453195.png) 8 | 9 | - 备选节点为 a,b,c,d,权值分别为 7,5,2,4 10 | - 选出 c 和 d 进行构造(权值最小),生成新节点为 e(权值为 6),备选节点变为 7,5,6 11 | - 选出 b 和 e 进行构造,生成新节点 f(权值为 11),备选节点为 7,11 12 | - 将最后的 7 和 11 节点进行构造,最后生成如图所示的哈夫曼树 13 | 14 | ## 哈夫曼树的应用 15 | 16 | 在处理字符串序列时,如果对每个字符串采用相同的二进制位来表示,则称这种编码方式为定长编码。若允许对不同的字符采用不等长的二进制位进行表示,那么这种方式称为可变长编码。可变长编码其特点是对使用频率高的字符采用短编码,而对使用频率低的字符则采用长编码的方式。这样我们就可以减少数据的存储空间,从而起到压缩数据的效果。而通过哈夫曼树形成的哈夫曼编码是一种的有效的数据压缩编码。 17 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/asana_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 238,Product of Array Except Self,60.1%,Medium,0.33156908645744715, https://leetcode.com/problems/product-of-array-except-self 3 | 98,Validate Binary Search Tree,27.8%,Medium,0.3036517978812848, https://leetcode.com/problems/validate-binary-search-tree 4 | 146,LRU Cache,33.2%,Medium,0.20247490080112324, https://leetcode.com/problems/lru-cache 5 | 973,K Closest Points to Origin,63.8%,Medium,0.10979229257099747, https://leetcode.com/problems/k-closest-points-to-origin 6 | 50,Pow(x;n),30.3%,Medium,0.008615395490835889, https://leetcode.com/problems/powx-n 7 | 53,Maximum Subarray,46.5%,Easy,0.008272628741228982, https://leetcode.com/problems/maximum-subarray 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/audible_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 545,Boundary of Binary Tree,38.9%,Medium,0.03736177747025919, https://leetcode.com/problems/boundary-of-binary-tree 3 | 472,Concatenated Words,43.7%,Hard,0.024011429628186427, https://leetcode.com/problems/concatenated-words 4 | 140,Word Break II,32.6%,Hard,0.010661081786113668, https://leetcode.com/problems/word-break-ii 5 | 937,Reorder Data in Log Files,54.3%,Easy,0.00802733590076424, https://leetcode.com/problems/reorder-data-in-log-files 6 | 73,Set Matrix Zeroes,43.1%,Medium,0.006699070439072842, https://leetcode.com/problems/set-matrix-zeroes 7 | 200,Number of Islands,46.8%,Medium,0.002765297303115152, https://leetcode.com/problems/number-of-islands 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/cloudera_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 1188,Design Bounded Blocking Queue,70.5%,Medium,0.07629083665191388, https://leetcode.com/problems/design-bounded-blocking-queue 3 | 622,Design Circular Queue,43.7%,Medium,0.05295034890955832, https://leetcode.com/problems/design-circular-queue 4 | 339,Nested List Weight Sum,74.0%,Easy,0.02960986116720276, https://leetcode.com/problems/nested-list-weight-sum 5 | 146,LRU Cache,33.2%,Medium,0.010321192540274932, https://leetcode.com/problems/lru-cache 6 | 173,Binary Search Tree Iterator,56.6%,Medium,0.008489015324911316, https://leetcode.com/problems/binary-search-tree-iterator 7 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/coupang_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 759,Employee Free Time,66.3%,Hard,0.04424979627369596, https://leetcode.com/problems/employee-free-time 3 | 1296,Divide Array in Sets of K Consecutive Numbers,53.8%,Medium,0.029539764622373135, https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers 4 | 114,Flatten Binary Tree to Linked List,49.3%,Medium,0.01482973297105031, https://leetcode.com/problems/flatten-binary-tree-to-linked-list 5 | 79,Word Search,35.6%,Medium,0.0016410260092945288, https://leetcode.com/problems/word-search 6 | 3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0014852223137141987, https://leetcode.com/problems/longest-substring-without-repeating-characters 7 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/drawbridge_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 757,Set Intersection Size At Least Two,40.1%,Hard,0.493754644718809, https://leetcode.com/problems/set-intersection-size-at-least-two 3 | 453,Minimum Moves to Equal Array Elements,50.2%,Easy,0.2605310833858301, https://leetcode.com/problems/minimum-moves-to-equal-array-elements 4 | 547,Friend Circles,58.6%,Medium,0.027307522052851193, https://leetcode.com/problems/friend-circles 5 | 54,Spiral Matrix,34.1%,Medium,0.014776167707688753, https://leetcode.com/problems/spiral-matrix 6 | 253,Meeting Rooms II,45.7%,Medium,0.008079219870546493, https://leetcode.com/problems/meeting-rooms-ii 7 | 1,Two Sum,45.6%,Easy,0.0008206138651873125, https://leetcode.com/problems/two-sum 8 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/3.2:杨氏矩阵查找.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | #define ROW 4 6 | #define COL 4 7 | 8 | bool YoungMatrix(int array[][COL], int searchkey){ 9 | int i = 0, j = COL - 1; 10 | int var = array[i][j]; 11 | while (true){ 12 | if (var == searchkey) 13 | return true; 14 | else if (var < searchkey && i < ROW - 1) 15 | var = array[++i][j]; 16 | else if (var > searchkey && j > 0) 17 | var = array[i][--j]; 18 | else 19 | return false; 20 | } 21 | } 22 | 23 | int main(){ 24 | int array[ROW][COL] = { { 1, 2, 8, 9 }, { 2, 4, 9, 12 }, { 4, 7, 10, 13 }, { 6, 8, 11, 15 } }; 25 | int searchkey; 26 | cin >> searchkey; 27 | if (YoungMatrix(array, searchkey)){ 28 | printf("存在"); 29 | } 30 | else{ 31 | printf("不存在"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/rubrik_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 166,Fraction to Recurring Decimal,21.6%,Medium,0.052923221534690555, https://leetcode.com/problems/fraction-to-recurring-decimal 3 | 51,N-Queens,46.6%,Hard,0.03651521297509749, https://leetcode.com/problems/n-queens 4 | 123,Best Time to Buy and Sell Stock III,37.5%,Hard,0.02516207671950806, https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii 5 | 4,Median of Two Sorted Arrays,29.6%,Hard,0.008754068159914991, https://leetcode.com/problems/median-of-two-sorted-arrays 6 | 64,Minimum Path Sum,54.5%,Medium,0.006127470152097104, https://leetcode.com/problems/minimum-path-sum 7 | 31,Next Permutation,32.6%,Medium,0.005989835219179644, https://leetcode.com/problems/next-permutation 8 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/docusign_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 92,Reverse Linked List II,38.8%,Medium,0.009429869252783295, https://leetcode.com/problems/reverse-linked-list-ii 3 | 73,Set Matrix Zeroes,43.1%,Medium,0.0070151111959223245, https://leetcode.com/problems/set-matrix-zeroes 4 | 146,LRU Cache,33.2%,Medium,0.004600353139061353, https://leetcode.com/problems/lru-cache 5 | 242,Valid Anagram,56.9%,Easy,0.004154123743115972, https://leetcode.com/problems/valid-anagram 6 | 49,Group Anagrams,56.9%,Medium,0.0038040939835560453, https://leetcode.com/problems/group-anagrams 7 | 2,Add Two Numbers,33.9%,Medium,0.00379539105290024, https://leetcode.com/problems/add-two-numbers 8 | 79,Word Search,35.6%,Medium,0.0016647248725526849, https://leetcode.com/problems/word-search 9 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/scheme/chapter06.scm: -------------------------------------------------------------------------------- 1 | (define (square x) (* x x)) 2 | 3 | (define (factor n) 4 | (define (helper r ret) 5 | (if (> (square r) n) ret 6 | (cond ((= 0 (remainder n r)) (helper (+ 1 r) (append ret (list r (/ n r))))) 7 | (else 8 | (helper (+ 1 r) ret))))) 9 | (helper 1 '())) 10 | 11 | (define (sum-factor n) 12 | (- (apply + (factor n)) n)) 13 | 14 | (define (isAmicable? n) 15 | (let ((ss (sum-factor n))) 16 | (and (not (= ss n)) (= n (sum-factor ss))))) 17 | 18 | (define (loop start stop ret) 19 | (if (> start stop) ret 20 | (begin (if (isAmicable? start) 21 | (loop (+ start 1) stop (cons start ret)) 22 | (loop (+ start 1) stop ret))))) 23 | 24 | (define (main n) 25 | (apply + (loop 2 n '()))) 26 | 27 | (display (main 10000)) 28 | (newline) 29 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/netflix_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 981,Time Based Key-Value Store,53.1%,Medium,0.0417652106742648, https://leetcode.com/problems/time-based-key-value-store 3 | 362,Design Hit Counter,63.7%,Medium,0.025382073271417165, https://leetcode.com/problems/design-hit-counter 4 | 295,Find Median from Data Stream,44.3%,Hard,0.00899893586856953, https://leetcode.com/problems/find-median-from-data-stream 5 | 155,Min Stack,44.5%,Easy,0.00474891074128171, https://leetcode.com/problems/min-stack 6 | 34,Find First and Last Position of Element in Sorted Array,36.2%,Medium,0.004247643638268045, https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array 7 | 56,Merge Intervals,39.3%,Medium,0.0034728286335985107, https://leetcode.com/problems/merge-intervals 8 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/2.4:寻找和为定值的两个数.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | //copyright@2014 July 6 | void twoSum(int data[], unsigned int length, int sum) 7 | { 8 | //sort(s, s+n); 如果数组非有序的,那就事先排好序O(N log N) 9 | 10 | int begin = 0; 11 | int end = length - 1; 12 | 13 | //俩头夹逼,或称两个指针两端扫描法,很经典的方法,O(N) 14 | while (begin < end) 15 | { 16 | long currSum = data[begin] + data[end]; 17 | 18 | if (currSum == sum) 19 | { 20 | //题目只要求输出满足条件的任意一对即可 21 | printf("%d %d\n", data[begin], data[end]); 22 | 23 | //如果需要所有满足条件的数组对,则需要加上下面两条语句: 24 | //begin++ 25 | //end-- 26 | break; 27 | } 28 | else{ 29 | if (currSum < sum) 30 | begin++; 31 | else 32 | end--; 33 | } 34 | } 35 | } 36 | 37 | int main(){ 38 | int a[] = { 1, 2, 4, 7, 11, 15 }; 39 | twoSum(a, 6, 15); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /02~数据结构/数组/数列/斐波那契数列.md: -------------------------------------------------------------------------------- 1 | # 斐波那契数列 2 | 3 | 斐波那契数列在数学和生活以及自然界中都非常有用。斐波那契数列最早被提出是印度数学家 Gopala,他在研究箱子包装物件长度恰好为 1 和 2 时的方法数时首先描述了这个数列。也就是这个问题:有 n 个台阶,你每次只能跨一阶或两阶,上楼有几种方法? 4 | 5 | 最早研究这个数列的当然就是斐波那契(Leonardo Fibonacci)了,他当时是为了描述如下情况的兔子生长数目: 6 | 7 | - 第一个月初有一对刚诞生的兔子 8 | - 第二个月之后(第三个月初)它们可以生育 9 | - 每月每对可生育的兔子会诞生下一对新兔子 10 | - 兔子永不死去 11 | 12 | ![](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/item/20230430222535.png) 13 | 14 | 斐波那契数列是编程书中讲递归必提的,因为它是按照递归定义的,所以我们就从递归开始讲起。 15 | 16 | ```cpp 17 | int Fib(int n) 18 | { 19 | return n < 2 ? 1 : (Fib(n-1) + Fib(n-2)); 20 | } 21 | ``` 22 | 23 | 这是编程最方便的解法,当然,也是效率最低的解法,原因是会出现大量的重复计算。为了避免这种情况,可以采用递推的方式。 24 | 25 | ```cpp 26 | int Fib[1000]; 27 | Fib[0] = 0;Fib[1] = 1; 28 | for(int i = 2;i < 1000;i++) Fib[i] = Fib[i-1] + Fib[i-2]; 29 | ``` 30 | 31 | ![](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/item/20230430222557.png) 32 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/samsung_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 312,Burst Balloons,51.8%,Hard,0.023366022786649468, https://leetcode.com/problems/burst-balloons 3 | 85,Maximal Rectangle,37.7%,Hard,0.012771565679487524, https://leetcode.com/problems/maximal-rectangle 4 | 5,Longest Palindromic Substring,29.5%,Medium,0.0021771085723255794, https://leetcode.com/problems/longest-palindromic-substring 5 | 15,3Sum,26.8%,Medium,0.002081166203824567, https://leetcode.com/problems/3sum 6 | 190,Reverse Bits,39.8%,Easy,0.001816201007777261, https://leetcode.com/problems/reverse-bits 7 | 1,Two Sum,45.6%,Easy,0.001767235914611495, https://leetcode.com/problems/two-sum 8 | 103,Binary Tree Zigzag Level Order Traversal,48.3%,Medium,0.0016881202574030904, https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal 9 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/square_6months.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 336,Palindrome Pairs,33.7%,Hard,0.09524900495801866, https://leetcode.com/problems/palindrome-pairs 3 | 999,Available Captures for Rook,66.7%,Easy,0.06736553182757604, https://leetcode.com/problems/available-captures-for-rook 4 | 72,Edit Distance,44.8%,Hard,0.039482058697133414, https://leetcode.com/problems/edit-distance 5 | 332,Reconstruct Itinerary,36.7%,Medium,0.013755375068485329, https://leetcode.com/problems/reconstruct-itinerary 6 | 273,Integer to English Words,27.1%,Hard,0.012081089250339716, https://leetcode.com/problems/integer-to-english-words 7 | 415,Add Strings,47.5%,Easy,0.007587289812159497, https://leetcode.com/problems/add-strings 8 | 91,Decode Ways,24.7%,Medium,0.005968385368349129, https://leetcode.com/problems/decode-ways 9 | -------------------------------------------------------------------------------- /01~算法基础/算法思维/分支限界法.md: -------------------------------------------------------------------------------- 1 | # 分支限界法 Branch and Bound Method 2 | 3 | 分支限界法类似于回溯法,也是一种在问题的解空间树上搜索问题解的算法,但在一般情况下,分支限界法与回溯法的求解目标不同。回溯法的求解目标是找出解空间树中满足约束条件的所有解,而分支限界法的求解目标则是找出满足约束条件的一个解,或是在满足约束条件的解中找出使某一目标函数值达到极大或极小的解,即在某种意义下的最优解。 4 | 5 | 由于求解目标不同,导致分支限界法与回溯法在解空间树上的搜索方式也不相同。回溯法以深度优先的方式搜索解空间树,而分支限界法则以广度优先或以最小耗费优先的方式搜索解空间树。 6 | 7 | 分支限界法的搜索策略:在扩展结点处,先生成其所有的儿子结点(分支),然后再从当前的活结点表中选择下一个扩展对点。为了有效地选择下一扩展结点,以加速搜索的进程,在每一活结点处,计算一个函数值(限界),并根据这些已计算出的函数值,从当前活结点表中选择一个最有利的结点作为扩展结点,使搜索朝着解空间树上有最优解的分支推进,以便尽快地找出一个最优解。 8 | 9 | 分支限界法常以广度优先或以最小耗费(最大效益)优先的方式搜索问题的解空间树。问题的解空间树是表示问题解空间的一棵有序树,常见的有子集树和排列树。在搜索问题的解空间树时,分支限界法与回溯法对当前扩展结点所使用的扩展方式不同。在分支限界法中,每一个活结点只有一次机会成为扩展结点。活结点一旦成为扩展结点,就一次性产生其所有儿子结点。在这些儿子结点中,那些导致不可行解或导致非最优解的儿子结点被舍弃,其余儿子结点被加入活结点表中。此后,从活结点表中取下一结点成为当前扩展结点,并重复上述结点扩展过程。这个过程一直持续到找到所求的解或或结点表为空时为止。 10 | 11 | 回溯法深度优先搜索堆栈活结点的所有可行子结点被遍历后才被从栈中弹出找出满足约束条件的所有解。分支限界法广度优先或最小消耗优先搜索队列、优先队列每个结点只有一次成为活结点的机会找出满足约束条件的一个解或特定意义下的最优解。 12 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/twilio_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 974,Subarray Sums Divisible by K,48.9%,Medium,0.2967998323621869, https://leetcode.com/problems/subarray-sums-divisible-by-k 3 | 146,LRU Cache,33.2%,Medium,0.2037051228192776, https://leetcode.com/problems/lru-cache 4 | 68,Text Justification,27.7%,Hard,0.16143214434637243, https://leetcode.com/problems/text-justification 5 | 332,Reconstruct Itinerary,36.7%,Medium,0.11747520126885172, https://leetcode.com/problems/reconstruct-itinerary 6 | 935,Knight Dialer,45.2%,Medium,0.09737416402517636, https://leetcode.com/problems/knight-dialer 7 | 560,Subarray Sum Equals K,43.9%,Medium,0.004279454482267064, https://leetcode.com/problems/subarray-sum-equals-k 8 | 14,Longest Common Prefix,35.4%,Easy,0.003320331762984143, https://leetcode.com/problems/longest-common-prefix 9 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/coupang_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 759,Employee Free Time,66.3%,Hard,0.03854298223800189, https://leetcode.com/problems/employee-free-time 3 | 1296,Divide Array in Sets of K Consecutive Numbers,53.8%,Medium,0.023832950586679065, https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers 4 | 114,Flatten Binary Tree to Linked List,49.3%,Medium,0.018398560423425723, https://leetcode.com/problems/flatten-binary-tree-to-linked-list 5 | 79,Word Search,35.6%,Medium,0.003688528772102895, https://leetcode.com/problems/word-search 6 | 56,Merge Intervals,39.3%,Medium,0.0033129067901687907, https://leetcode.com/problems/merge-intervals 7 | 3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0014852223137141987, https://leetcode.com/problems/longest-substring-without-repeating-characters 8 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/erlang/1.1:左旋转字符串.erl: -------------------------------------------------------------------------------- 1 | %%%----------------------------------- 2 | %%% @Module : july_1_1 3 | %%% @Author : hejavac 4 | %%% @Email : hejavac@gmail.com 5 | %%% @Created : 创建日期 6 | %%% @Description : 1.1、左旋转字符串 : 字符串旋转问题,例如abcdef 左旋2位 变成 cdefab 7 | %%%----------------------------------- 8 | 9 | -module(july_1_1). 10 | 11 | -compile(export_all). 12 | 13 | %% 启动 14 | %% Str:字符串 15 | %% Step:位移量 16 | %% 返回:位移后的字符串 17 | start(Str, Step) -> 18 | shift(Str, Step). 19 | 20 | %% 字符串位移递归函数 21 | %% Str:字符串 22 | %% Step:位移量 23 | %% 返回:位移后的字符串 24 | shift(S, 0) -> 25 | S; 26 | shift([T|S], Step) -> 27 | %或者是:shift(lists:concat([S, [T]]), Step-1). 28 | shift(S ++ [T], Step-1). 29 | 30 | %% 测试(bcdef 左旋2位 变成 cdefab) 31 | test() -> 32 | dbg:tracer(), 33 | dbg:p(all,[c]), 34 | dbg:tpl(?MODULE, [{'_', [], [{return_trace}]}]), 35 | start("abcdef", 2). 36 | -------------------------------------------------------------------------------- /02~数据结构/时间日期/时区.md: -------------------------------------------------------------------------------- 1 | ## 时区与偏移 2 | 3 | 人们经常会把时区与 UTC 偏移量搞混,UTC 偏移量代表了某个具体的时间值与 UTC 时间之间的差异,通常用 HH:mm 形式表述。而 TimeZone 则表示某个地理区域,某个 TimeZone 中往往会包含多个偏移量,而多个时区可能在一年的某些时间有相同的偏移量。譬如 America/Chicago, America/Denver, 以及 America/Belize 在一年中不同的时间都会包含 -06:00 这个偏移。 4 | 5 | ### CST 6 | 7 | CST 却同时可以代表如下 4 个不同的时区: 8 | 9 | - Central Standard Time (USA) UT-6:00 10 | - Central Standard Time (Australia) UT+9:30 11 | - China Standard Time UT+8:00 12 | - Cuba Standard Time UT-4:00 13 | 14 | ### CET 15 | 16 | (英語:Central European Time,CET)欧洲中部时间是比世界标准时间(UTC)早一个小时的时区名称之一。它被大部分欧洲国家和部分北非国家采用。冬季时间为 UTC+1,夏季欧洲夏令时为 UTC+2。 17 | 18 | ### DST 19 | 20 | Daylight Saving Time 夏日节约时间,是指在夏天太阳升起的比较早时,将时钟拨快一小时,以提早日光的使用,在英国则称为夏令时间(Summer Time)。这个构想于 1784 年由美国班杰明·富兰克林提出来,1915 年德国成为第一个正式实施夏令日光节约时间的国家,以削减灯光照明和耗电开支。自此以后,全球以欧洲和北美为主的约 70 个国家都引用这个做法。目前被划分成两个时区的印度也正在商讨是否全国该统一实行夏令日光节约时间。欧洲手机上也有很多 GSM 系统的基地台,除了会传送当地时间外也包括夏令日光节约时间,做为手机的时间标准,使用者可以自行决定要开启或关闭。 21 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/python/2.6:求连续子数组的最大和.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Author: tdoly 5 | ''' 6 | 7 | 8 | def max_sum(ls): 9 | #判断列表 10 | if len(ls) > 0: 11 | #将列表的第一个元素赋值给result,用以判断全为负数的情况,mark初始值为0 12 | result, mark = ls[0], 0 13 | else: 14 | result = None 15 | for element in ls: 16 | #第一次循环,或者mark值为正数时,累加 17 | if mark >= 0: 18 | mark += element 19 | else: 20 | mark = element 21 | # 对比mark和result的值 22 | if mark > result: 23 | result = mark 24 | return result 25 | 26 | 27 | def test(): 28 | lss = [[1, -2, 3, 10, -4, 7, 2, -5], 29 | [1, 3, 10, -4, 7, 2], 30 | [-2, -2, -1, -1, -2], 31 | [-10, -3, -2, -14, 2], 32 | []] 33 | for ls in lss: 34 | print max_sum(ls) 35 | 36 | 37 | if __name__ == '__main__': 38 | test() 39 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/qualcomm_1year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 160,Intersection of Two Linked Lists,40.6%,Easy,0.009840575641962807, https://leetcode.com/problems/intersection-of-two-linked-lists 3 | 191,Number of 1 Bits,49.8%,Easy,0.007169774395423815, https://leetcode.com/problems/number-of-1-bits 4 | 237,Delete Node in a Linked List,63.8%,Easy,0.004902571407932664, https://leetcode.com/problems/delete-node-in-a-linked-list 5 | 206,Reverse Linked List,62.5%,Easy,0.002231770161393673, https://leetcode.com/problems/reverse-linked-list 6 | 1,Two Sum,45.6%,Easy,0.001767235914611495, https://leetcode.com/problems/two-sum 7 | 2,Add Two Numbers,33.9%,Medium,0.0016196302686159038, https://leetcode.com/problems/add-two-numbers 8 | 151,Reverse Words in a String,21.9%,Medium,0.0015260771341435947, https://leetcode.com/problems/reverse-words-in-a-string 9 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/js/1.1:左旋转字符串/tests.js: -------------------------------------------------------------------------------- 1 | // 1. 暴力移位法 2 | test('暴力移位法', function () { 3 | ok(leftShift1('abcdef', 0) == 'abcdef', 'abcdef 左旋转 0 位变成 abcdef'); 4 | ok(leftShift1('abcdef', 2) == 'cdefab', 'abcdef 左旋转 2 位变成 cdefab'); 5 | ok(leftShift1('abcdef', 6) == 'abcdef', 'abcdef 左旋转 6 位变成 abcdef'); 6 | ok(leftShift1('abcdef', 8) == 'cdefab', 'abcdef 左旋转 8 位变成 cdefab'); 7 | ok(leftShift1('abcdef', 15) == 'defabc', 'abcdef 左旋转 15 位变成 defabc'); 8 | }); 9 | 10 | // 2. 三步翻转法 11 | test('三步翻转法', function () { 12 | ok(leftShift2('abcdef', 0) == 'abcdef', 'abcdef 左旋转 0 位变成 abcdef'); 13 | ok(leftShift2('abcdef', 2) == 'cdefab', 'abcdef 左旋转 2 位变成 cdefab'); 14 | ok(leftShift2('abcdef', 6) == 'abcdef', 'abcdef 左旋转 6 位变成 abcdef'); 15 | ok(leftShift2('abcdef', 8) == 'cdefab', 'abcdef 左旋转 8 位变成 cdefab'); 16 | ok(leftShift2('abcdef', 15) == 'defabc', 'abcdef 左旋转 15 位变成 defabc'); 17 | }); 18 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/java/chapter2/HashTableCompare.java: -------------------------------------------------------------------------------- 1 | class HashTableCompare implements ICompare { 2 | @Override 3 | public boolean compare(String longString, String shortString) { 4 | int[] hash = new int[26]; 5 | 6 | int num = 0; 7 | 8 | for (int j = 0; j < shortString.length(); j++) { 9 | int index = shortString.charAt(j) - 'A'; 10 | if (hash[index] == 0) { 11 | num++; 12 | } 13 | hash[index]++; 14 | } 15 | 16 | for (int k = 0; k < longString.length(); k++) { 17 | int index = longString.charAt(k) - 'A'; 18 | hash[index]--; 19 | if (hash[index] == 0) { 20 | num--; 21 | if (num == 0) { 22 | break; 23 | } 24 | } 25 | } 26 | 27 | return num == 0; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/python/chapter04.py: -------------------------------------------------------------------------------- 1 | def strstr(haystack, needle): 2 | return any( 3 | all((haystack[i + j] == needle[j] for j in xrange(0, len(needle)))) 4 | for i in xrange(0, len(haystack) - len(needle) + 1)) 5 | 6 | 7 | def test_strstr(): 8 | print "test_strstr" 9 | print strstr("abcdf", "cd") is True 10 | print strstr("abcdf", "ef") is False 11 | 12 | 13 | def find_no_repeat_char(string): 14 | maxchar = 256 15 | charlst = [0 for i in xrange(maxchar)] 16 | for c in string: 17 | charlst[ord(c)] += 1 18 | for i in xrange(0, maxchar): 19 | if charlst[i] == 1: 20 | return chr(i) 21 | 22 | 23 | def test_find_no_repeat_char(): 24 | print "test_find_no_repeat_char" 25 | s = "abaccdeff" 26 | print find_no_repeat_char(s) is "b" 27 | 28 | 29 | if __name__ == "__main__": 30 | test_strstr() 31 | test_find_no_repeat_char() 32 | -------------------------------------------------------------------------------- /02~数据结构/数组/滑动窗口/滑动窗口均值/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestMovingAverage(t *testing.T) { 10 | movingAverage := New(3) 11 | 12 | movingAverage.Add(1) 13 | assert.Equal(t, movingAverage.GetAverage(), float64(1)) 14 | assert.Equal(t, movingAverage.GetSum(), 1) 15 | 16 | movingAverage.Add(2) 17 | assert.Equal(t, movingAverage.GetAverage(), float64(1.5)) 18 | assert.Equal(t, movingAverage.GetSum(), 3) 19 | 20 | movingAverage.Add(3) 21 | assert.Equal(t, movingAverage.GetAverage(), float64(2)) 22 | assert.Equal(t, movingAverage.GetSum(), 6) 23 | 24 | movingAverage.Add(4) 25 | assert.Equal(t, movingAverage.GetAverage(), float64(3)) 26 | assert.Equal(t, movingAverage.GetSum(), 9) 27 | 28 | movingAverage.Add(5) 29 | assert.Equal(t, movingAverage.GetAverage(), float64(4)) 30 | assert.Equal(t, movingAverage.GetSum(), 12) 31 | } 32 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/7.2:最短摘要的生成.c: -------------------------------------------------------------------------------- 1 | //July、updated,2011.10.21 2 | int nTargetLen = N + 1; // 设置目标长度为总长度+1 3 | int pBegin = 0; // 初始指针 4 | int pEnd = 0; // 结束指针 5 | int nLen = N; // 目标数组的长度为N 6 | int nAbstractBegin = 0; // 目标摘要的起始地址 7 | int nAbstractEnd = 0; // 目标摘要的结束地址 8 | 9 | while(true) 10 | { 11 | // 假设未包含所有的关键词,并且后面的指针没有越界,往后移动指针 12 | while(!isAllExisted() && pEnd < nLen) 13 | { 14 | pEnd++; 15 | } 16 | 17 | // 假设找到一段包含所有关键词信息的字符串 18 | while(isAllExisted()) 19 | { 20 | if(pEnd – pBegin < nTargetLen) 21 | { 22 | nTargetLen = pEnd – pBegin; 23 | nAbstractBegin = pBegin; 24 | nAbstractEnd = pEnd – 1; 25 | } 26 | pBegin++; 27 | } 28 | if(pEnd >= N) 29 | Break; 30 | } 31 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/src/java/main/InsertSort.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | /** 4 | * 插入排序 5 | */ 6 | public class InsertSort implements IArraySort { 7 | 8 | @Override 9 | public int[] sort(int[] sourceArray) throws Exception { 10 | // 对 arr 进行拷贝,不改变参数内容 11 | int[] arr = Arrays.copyOf(sourceArray, sourceArray.length); 12 | 13 | // 从下标为1的元素开始选择合适的位置插入,因为下标为0的只有一个元素,默认是有序的 14 | for (int i = 1; i < arr.length; i++) { 15 | 16 | // 记录要插入的数据 17 | int tmp = arr[i]; 18 | 19 | // 从已经排序的序列最右边的开始比较,找到比其小的数 20 | int j = i; 21 | while (j > 0 && tmp < arr[j - 1]) { 22 | arr[j] = arr[j - 1]; 23 | j--; 24 | } 25 | 26 | // 存在比其小的数,插入 27 | if (j != i) { 28 | arr[j] = tmp; 29 | } 30 | 31 | } 32 | return arr; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/java/chapter2/SortAndCompare.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | class SortAndCompare implements ICompare { 4 | @Override 5 | public boolean compare(String longString, String shortString) { 6 | char[] longStr = longString.toCharArray(); 7 | char[] shortStr = shortString.toCharArray(); 8 | Arrays.sort(longStr); 9 | Arrays.sort(shortStr); 10 | 11 | int posShort = 0, posLong = 0; 12 | while (posShort < shortStr.length && posLong < longStr.length) { 13 | while (posLong < longStr.length && longStr[posLong] < shortStr[posShort]) { 14 | posLong++; 15 | } 16 | 17 | if (posLong == longStr.length || longStr[posLong] != shortStr[posShort]) { 18 | break; 19 | } 20 | 21 | posShort++; 22 | } 23 | return posShort == shortStr.length; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/appdynamics_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 346,Moving Average from Data Stream,70.9%,Easy,0.02398572412300405, https://leetcode.com/problems/moving-average-from-data-stream 3 | 394,Decode String,50.0%,Medium,0.0169360560557796, https://leetcode.com/problems/decode-string 4 | 221,Maximal Square,37.7%,Medium,0.00988638798855515, https://leetcode.com/problems/maximal-square 5 | 380,Insert Delete GetRandom O(1),47.5%,Medium,0.009820849864094454, https://leetcode.com/problems/insert-delete-getrandom-o1 6 | 124,Binary Tree Maximum Path Sum,34.3%,Hard,0.005531752454833179, https://leetcode.com/problems/binary-tree-maximum-path-sum 7 | 200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands 8 | 5,Longest Palindromic Substring,29.5%,Medium,0.002279333142507479, https://leetcode.com/problems/longest-palindromic-substring 9 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/factset_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 881,Boats to Save People,46.8%,Medium,0.14464600498431196, https://leetcode.com/problems/boats-to-save-people 3 | 168,Excel Sheet Column Title,31.1%,Easy,0.12859286438561013, https://leetcode.com/problems/excel-sheet-column-title 4 | 171,Excel Sheet Column Number,55.9%,Easy,0.07885939025485048, https://leetcode.com/problems/excel-sheet-column-number 5 | 1,Two Sum,45.6%,Easy,0.02912591612409083, https://leetcode.com/problems/two-sum 6 | 206,Reverse Linked List,62.5%,Easy,0.01453513961911317, https://leetcode.com/problems/reverse-linked-list 7 | 1081,Smallest Subsequence of Distinct Characters,50.4%,Medium,0, https://leetcode.com/problems/smallest-subsequence-of-distinct-characters 8 | 1209,Remove All Adjacent Duplicates in String II,56.9%,Medium,0, https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii 9 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/box_alltime.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 250,Count Univalue Subtrees,52.0%,Medium,1.7195134036164268, https://leetcode.com/problems/count-univalue-subtrees 3 | 965,Univalued Binary Tree,67.7%,Easy,1.2504050329534637, https://leetcode.com/problems/univalued-binary-tree 4 | 68,Text Justification,27.7%,Hard,0.7812966622905007, https://leetcode.com/problems/text-justification 5 | 935,Knight Dialer,45.2%,Medium,0.5465437063680699, https://leetcode.com/problems/knight-dialer 6 | 191,Number of 1 Bits,49.8%,Easy,0.3920623591078002, https://leetcode.com/problems/number-of-1-bits 7 | 126,Word Ladder II,22.1%,Hard,0.10749169745614619, https://leetcode.com/problems/word-ladder-ii 8 | 1,Two Sum,45.6%,Easy,0.07147453361485057, https://leetcode.com/problems/two-sum 9 | 23,Merge k Sorted Lists,40.2%,Hard,0.0250564321052577, https://leetcode.com/problems/merge-k-sorted-lists 10 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/c/3.1:二分查找实现.c: -------------------------------------------------------------------------------- 1 | //二分查找V0.1实现版 2 | //copyright@2011 July 3 | 4 | //首先要把握下面几个要点: 5 | //right = n-1 => while(left <= right) => right = middle-1; 6 | //right = n => while(left < right) => right = middle; 7 | //middle的计算不能写在while循环外,否则无法得到更新。 8 | 9 | int binary_search(int array[], int n, int value) 10 | { 11 | int left = 0; 12 | int right = n - 1; 13 | //如果这里是int right = n 的话,那么下面有两处地方需要修改,以保证一一对应: 14 | //1、下面循环的条件则是while(left < right) 15 | //2、循环内当 array[middle] > value 的时候,right = mid 16 | 17 | while (left <= right) //循环条件,适时而变 18 | { 19 | int middle = left + ((right - left) >> 1); //防止溢出,移位也更高效。同时,每次循环都需要更新。 20 | 21 | if (array[middle] > value) 22 | { 23 | right = middle - 1; //right赋值,适时而变 24 | } 25 | else if(array[middle] < value) 26 | { 27 | left = middle + 1; 28 | } 29 | else 30 | return middle; 31 | //可能会有读者认为刚开始时就要判断相等,但毕竟数组中不相等的情况更多 32 | //如果每次循环都判断一下是否相等,将耗费时间 33 | } 34 | return -1; 35 | } 36 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/box_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 250,Count Univalue Subtrees,52.0%,Medium,1.1142520926168622, https://leetcode.com/problems/count-univalue-subtrees 3 | 965,Univalued Binary Tree,67.7%,Easy,0.8592043555602473, https://leetcode.com/problems/univalued-binary-tree 4 | 68,Text Justification,27.7%,Hard,0.6976918484065334, https://leetcode.com/problems/text-justification 5 | 935,Knight Dialer,45.2%,Medium,0.44264411134991843, https://leetcode.com/problems/knight-dialer 6 | 191,Number of 1 Bits,49.8%,Easy,0.20448184426913651, https://leetcode.com/problems/number-of-1-bits 7 | 126,Word Ladder II,22.1%,Hard,0.04004093605556132, https://leetcode.com/problems/word-ladder-ii 8 | 23,Merge k Sorted Lists,40.2%,Hard,0.009092808657599025, https://leetcode.com/problems/merge-k-sorted-lists 9 | 1,Two Sum,45.6%,Easy,0.00184543512358731, https://leetcode.com/problems/two-sum 10 | -------------------------------------------------------------------------------- /10~LeetCode/99~参考资料/2024~LeetCode Questions CompanyWise/pocket-gems_2year.csv: -------------------------------------------------------------------------------- 1 | ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link 2 | 740,Delete and Earn,48.6%,Medium,0.35086940302246983, https://leetcode.com/problems/delete-and-earn 3 | 547,Friend Circles,58.6%,Medium,0.21411487503668122, https://leetcode.com/problems/friend-circles 4 | 1010,Pairs of Songs With Total Durations Divisible by 60,47.4%,Easy,0.166463766150424, https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 5 | 366,Find Leaves of Binary Tree,70.6%,Medium,0.15413619386178415, https://leetcode.com/problems/find-leaves-of-binary-tree 6 | 133,Clone Graph,34.8%,Medium,0.017381665875995565, https://leetcode.com/problems/clone-graph 7 | 10,Regular Expression Matching,26.8%,Hard,0.01542711432325032, https://leetcode.com/problems/regular-expression-matching 8 | 41,First Missing Positive,32.0%,Hard,0.006163347707668678, https://leetcode.com/problems/first-missing-positive 9 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/src/java/main/ShellSort.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | /** 4 | * 希尔排序 5 | */ 6 | public class ShellSort implements IArraySort { 7 | 8 | @Override 9 | public int[] sort(int[] sourceArray) throws Exception { 10 | // 对 arr 进行拷贝,不改变参数内容 11 | int[] arr = Arrays.copyOf(sourceArray, sourceArray.length); 12 | 13 | int gap = 1; 14 | while (gap < arr.length) { 15 | gap = gap * 3 + 1; 16 | } 17 | 18 | while (gap > 0) { 19 | for (int i = gap; i < arr.length; i++) { 20 | int tmp = arr[i]; 21 | int j = i - gap; 22 | while (j >= 0 && arr[j] > tmp) { 23 | arr[j + gap] = arr[j]; 24 | j -= gap; 25 | } 26 | arr[j + gap] = tmp; 27 | } 28 | gap = (int) Math.floor(gap / 3); 29 | } 30 | 31 | return arr; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/src/java/main/BubbleSort.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | /** 4 | * 冒泡排序 5 | */ 6 | public class BubbleSort implements IArraySort { 7 | 8 | @Override 9 | public int[] sort(int[] sourceArray) throws Exception { 10 | // 对 arr 进行拷贝,不改变参数内容 11 | int[] arr = Arrays.copyOf(sourceArray, sourceArray.length); 12 | 13 | for (int i = 1; i < arr.length; i++) { 14 | // 设定一个标记,若为true,则表示此次循环没有进行交换,也就是待排序列已经有序,排序已经完成。 15 | boolean flag = true; 16 | 17 | for (int j = 0; j < arr.length - i; j++) { 18 | if (arr[j] > arr[j + 1]) { 19 | int tmp = arr[j]; 20 | arr[j] = arr[j + 1]; 21 | arr[j + 1] = tmp; 22 | 23 | flag = false; 24 | } 25 | } 26 | 27 | if (flag) { 28 | break; 29 | } 30 | } 31 | return arr; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /03~排序/99~参考资料/2018~《十大经典排序算法》/src/java/main/SelectionSort.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | /** 4 | * 选择排序 5 | */ 6 | public class SelectionSort implements IArraySort { 7 | 8 | @Override 9 | public int[] sort(int[] sourceArray) throws Exception { 10 | int[] arr = Arrays.copyOf(sourceArray, sourceArray.length); 11 | 12 | // 总共要经过 N-1 轮比较 13 | for (int i = 0; i < arr.length - 1; i++) { 14 | int min = i; 15 | 16 | // 每轮需要比较的次数 N-i 17 | for (int j = i + 1; j < arr.length; j++) { 18 | if (arr[j] < arr[min]) { 19 | // 记录目前能找到的最小值元素的下标 20 | min = j; 21 | } 22 | } 23 | 24 | // 将找到的最小值和i位置所在的值进行交换 25 | if (i != min) { 26 | int tmp = arr[i]; 27 | arr[i] = arr[min]; 28 | arr[min] = tmp; 29 | } 30 | 31 | } 32 | return arr; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /99~参考资料/《程序员编程技艺》/code/go/3.2-杨氏矩阵查找.go: -------------------------------------------------------------------------------- 1 | // 3.2 杨氏矩阵查找 2 | // @author leiyonglin 3 | // http://play.golang.org/p/EcFyPADISb 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | ) 10 | 11 | //解法二:定位法 12 | func find2(arr [][]int, s int) bool { 13 | n := len(arr) 14 | if n == 0 { 15 | return false 16 | } 17 | m := len(arr[0]) 18 | if m == 0 { 19 | return false 20 | } 21 | 22 | x := m - 1 23 | y := 0 24 | 25 | for x >= 0 && y < n { 26 | if arr[y][x] > s { 27 | x-- 28 | } else if arr[y][x] < s { 29 | y++ 30 | } else { 31 | return true 32 | } 33 | 34 | } 35 | return false 36 | } 37 | 38 | func main() { 39 | arr := [][]int{ 40 | []int{1, 2, 8, 9}, 41 | []int{2, 4, 9, 12}, 42 | []int{4, 7, 10, 13}, 43 | []int{6, 8, 11, 15}, 44 | } 45 | 46 | fmt.Println("数组:", arr) 47 | 48 | s := 10 49 | fmt.Printf("%d 是否在数组中: %t \n", s, find2(arr, s)) 50 | 51 | s = 16 52 | fmt.Printf("%d 是否在数组中: %t \n", s, find2(arr, s)) 53 | 54 | } 55 | --------------------------------------------------------------------------------