├── .gitattributes ├── .gitignore ├── 2020届_笔试面试_C++刷题笔记.sln └── 2020届_笔试面试_C++刷题笔记 ├── 0-1背包扩展:多重背包问题.cpp ├── 0-1背包扩展:完全背包问题.cpp ├── 0-1背包扩展:背包必须装满.cpp ├── 0-1背包问题(经典).cpp ├── 1.strlen:计算字符串长度.cpp ├── 10.strchr:字符串中找首次出现某个字符的字符串.cpp ├── 1元一瓶水,两个瓶子兑换一瓶水,问总共能喝几瓶水.cpp ├── 2.strcmp:比较字符串大小.cpp ├── 2020届_笔试面试_C++刷题笔记.vcxproj ├── 2020届_笔试面试_C++刷题笔记.vcxproj.filters ├── 3.strcpy:用于字符串复制(复制包含0).cpp ├── 4.strstr:寻找母串中是否存在某个子串.cpp ├── 5.itoa:整数转字符串.cpp ├── 6.atoi:字符串转整数(遇到非数字字符结束).cpp ├── 7.memcpy:拷贝某段内存.cpp ├── 8.memset:对指定内存每个字节赋某个值.cpp ├── 9.strcat:字符串连接.cpp ├── Base64加密.cpp ├── LCS_最长公共子序列.cpp ├── LIS_最长上升子序列.cpp ├── LeetCode520_检测大写字母.cpp ├── N个数,判断是否有重复的值.cpp ├── algorithm.cpp ├── algorithm2.cpp ├── algorithm3.cpp ├── deque.cpp ├── forward_list.cpp ├── list.cpp ├── main__爱奇艺第一题.cpp ├── main__爱奇艺第二题.cpp ├── map.cpp ├── set.cpp ├── stack_and_queue.cpp ├── string.cpp ├── vector.cpp ├── 一个特殊栈,有栈的基本功能,且可以返回栈中的最小元素.cpp ├── 万万没想到之抓捕孔连顺(组合).cpp ├── 不同进制的输入与输出方法(与十进制之间的转换).cpp ├── 两个单链表相交的一系列问题.cpp ├── 两个栈实现队列.cpp ├── 两个超长的整数字符串相加.cpp ├── 主函数_排序算法调用.cpp ├── 之_字形_打印矩阵.cpp ├── 二分查找算法.cpp ├── 二叉树中找前继和后继节点.cpp ├── 二叉树的序列化与反序列化.cpp ├── 二叉树的遍历.cpp ├── 人民币组合问题.cpp ├── 从尾到头打印链表(链表反转).cpp ├── 以数组创建一个单链表.cpp ├── 任务列表.cpp ├── 任务调度问题(拼多多一道题).cpp ├── 偶串(子串的偶串个数).cpp ├── 冒泡法排序.cpp ├── 冒泡法排序.h ├── 删除字符串中出现次数最少的字符.cpp ├── 判断一个链表是否为回文结构.cpp ├── 加密通信问题(异或).cpp ├── 单向和双向链表反转.cpp ├── 发工资问题(广度优先搜索).cpp ├── 叠加箱子(唐莉写的).cpp ├── 叠加箱子(我写的).cpp ├── 基数排序.cpp ├── 堆排序_大根堆_下标从0开始.cpp ├── 堆排序_大根堆_下标从1开始.cpp ├── 堆排序_小根堆_下标从0开始.cpp ├── 复制含有随机指针节点的链表.cpp ├── 大端、小端判断.cpp ├── 字符、字符串、int、int数组相互转换.cpp ├── 字符串中查找子串.cpp ├── 字符串匹配的KMP算法.cpp ├── 字符串去重(两两、三三重复).cpp ├── 字符串大小写转换.cpp ├── 字符串最大映射.cpp ├── 学习机(并查集).cpp ├── 密码锁(矩阵是否沿中心对称).cpp ├── 将单链表按某值划分成左边小,中间相等,右边大的形式.cpp ├── 小和问题(所有左边数比右边数小的左边数之和).cpp ├── 小明上学闹钟问题.cpp ├── 小明跑步(弧长与角度公式).cpp ├── 工资排序(统计出现次数).cpp ├── 希尔排序算法.cpp ├── 希尔排序算法.h ├── 常用排序算法复习测试.cpp ├── 归并算法排序.cpp ├── 归并算法排序.h ├── 快速排序算法.cpp ├── 快速排序算法.h ├── 打印两个有序链表的公共部分.cpp ├── 找出字符串中第一个不重复的字符.cpp ├── 找老乡(并查集).cpp ├── 找质数__第二题.cpp ├── 报文转义__第一题.cpp ├── 排列组合问题.cpp ├── 排序(只能是0位置与某个位置交换).cpp ├── 插入法排序.cpp ├── 插入法排序.h ├── 数学期望.cpp ├── 数组排序后,相邻两数的最大差值.cpp ├── 整数取偶数位上的数.cpp ├── 斐波那契数列.cpp ├── 旋转数组的最小数字.cpp ├── 旋转正方形矩阵.cpp ├── 最长子序列(特殊).cpp ├── 栈.cpp ├── 栈_实现_队列.cpp ├── 栈(固定大小数组实现).cpp ├── 桶排序(计数排序).cpp ├── 源.cpp ├── 源1-1.cpp ├── 源1-2.cpp ├── 源1.cpp ├── 源10.cpp ├── 源11.cpp ├── 源12.cpp ├── 源13.cpp ├── 源14.cpp ├── 源15.cpp ├── 源16.cpp ├── 源2-1.cpp ├── 源2-2.cpp ├── 源2.cpp ├── 源3-1.cpp ├── 源3-2.cpp ├── 源3.cpp ├── 源4.cpp ├── 源5.cpp ├── 源6.cpp ├── 源7.cpp ├── 源8.cpp ├── 源9.cpp ├── 猫狗队列问题.cpp ├── 用两个栈实现队列.cpp ├── 笔试题__Zoom.cpp ├── 网易互娱__第一题.cpp ├── 网易互娱__第三题.cpp ├── 网易互娱__第二题.cpp ├── 荷兰国国旗问题(快排的partition过程).cpp ├── 裂变反应堆(组合的应用法).cpp ├── 裂变反应堆(背包问题升级_多个限制条件的背包问题).cpp ├── 谓词的写法.cpp ├── 转圈打印矩阵.cpp ├── 逆序对问题(左边数比右边数大,则这两个数构成一个逆序对).cpp ├── 选择法排序.cpp ├── 选择法排序.h ├── 通讯软件__第三题(并查集).cpp ├── 重建二叉树(前序+中序的值).cpp ├── 重建二叉树(序列化与反序列化).cpp ├── 链表的成对反转.cpp ├── 键入个数_一维数组.cpp ├── 键入个数_二维数组.cpp ├── 队列_实现_栈.cpp ├── 队列(固定大小数组实现).cpp ├── 面试题3__数组中重复的数字.cpp ├── 面试题4__二维数组中的查找(有序的二维数组).cpp └── 面试题5__替换空格(字符串查找和替换).cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.572 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2020届_笔试面试_C++刷题笔记", "2020届_笔试面试_C++刷题笔记\2020届_笔试面试_C++刷题笔记.vcxproj", "{A10237B7-B1DA-4F84-B832-C702E4B5C924}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A10237B7-B1DA-4F84-B832-C702E4B5C924}.Debug|x64.ActiveCfg = Debug|x64 17 | {A10237B7-B1DA-4F84-B832-C702E4B5C924}.Debug|x64.Build.0 = Debug|x64 18 | {A10237B7-B1DA-4F84-B832-C702E4B5C924}.Debug|x86.ActiveCfg = Debug|Win32 19 | {A10237B7-B1DA-4F84-B832-C702E4B5C924}.Debug|x86.Build.0 = Debug|Win32 20 | {A10237B7-B1DA-4F84-B832-C702E4B5C924}.Release|x64.ActiveCfg = Release|x64 21 | {A10237B7-B1DA-4F84-B832-C702E4B5C924}.Release|x64.Build.0 = Release|x64 22 | {A10237B7-B1DA-4F84-B832-C702E4B5C924}.Release|x86.ActiveCfg = Release|Win32 23 | {A10237B7-B1DA-4F84-B832-C702E4B5C924}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {91C16958-CFE4-4309-89A3-B6C177A37532} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/0-1背包扩展:多重背包问题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/0-1背包扩展:多重背包问题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/0-1背包扩展:完全背包问题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/0-1背包扩展:完全背包问题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/0-1背包扩展:背包必须装满.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/0-1背包扩展:背包必须装满.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/0-1背包问题(经典).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 博客:https://blog.csdn.net/hongtao_6/article/details/93924799 3 | 博客:https://blog.csdn.net/laoniu_c/article/details/38453083 4 | 动态规划解答 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | 12 | // 打印二维数组vector> array 13 | static void print_2D_Array(vector> array) 14 | { 15 | for (unsigned i = 0; i < array.size(); ++i) 16 | { 17 | for (vector::iterator it = array[i].begin(); it != array[i].end(); it++) 18 | { 19 | cout << *it << " "; 20 | } 21 | cout << endl; 22 | } 23 | cout << endl; 24 | } 25 | 26 | /*************************************** 27 | n件物品,每件物品重weight,价值value;背包最大容量是c. 28 | ***************************************/ 29 | static vector knasSack(int n, int c, vector &weight, vector &value) 30 | { 31 | // 最大价值表,n+1行(第i行代表第i件物品),每一行是一个一维数组vector(c + 1, 0),即,c+1列(第i列代表背包重量为i) 32 | vector> maxValue_table(n + 1, vector(c + 1, 0)); 33 | // 记录物品选或不选,下标从0开始。 34 | vector result(n, false); 35 | // 创建动态规划表。 36 | for (int i = 1; i <= n; i++) // 第0行不使用,没有0号物品 37 | { 38 | for (int j = 1; j <= c; j++) // 第0行背包容量为0(初始化为0即可) 39 | { 40 | if (i == 1) // 第1行(第1件物品,下标为0),只有一件物品,只要能放下,直接放。 41 | { 42 | maxValue_table[i][j] = (weight[i - 1] <= j ? value[i - 1] : 0); 43 | } 44 | else 45 | { 46 | // 上一个网格的值,即,不加第i件物品:前面i-1件物品的最大价值 47 | int frontValue = maxValue_table[i - 1][j]; 48 | // 加第i件物品:当前商品的价值 + 剩余空间的价值 49 | int thisValue = (weight[i - 1] <= j ? value[i - 1] + maxValue_table[i - 1][j - weight[i - 1]] : frontValue); 50 | // 返回 topValue和thisValue中较大的一个 51 | maxValue_table[i][j] = (frontValue > thisValue ? frontValue : thisValue); 52 | } 53 | } 54 | } 55 | print_2D_Array(maxValue_table); 56 | 57 | // 动态规划表创建好了,现在根据物品件数和背包容量来选择最大价值的装载。 58 | for (int i = n, j = c; i > 0; i--) // 从右下角开始。 59 | { // 同一列中,如果下面的数比上面的数大,说明当前行选了的。 60 | if (maxValue_table[i][j] > maxValue_table[i - 1][j]) 61 | { 62 | result[i - 1] = true; 63 | j = j - weight[i - 1]; 64 | } 65 | } 66 | return result; 67 | } 68 | 69 | 70 | int main_背包问题_经典(void) // main_背包问题_经典 71 | { 72 | int n = 5; // 物品件数 73 | int c = 10; // 背包最大容量 74 | vector weight = { 2,2,6,5,4 }; 75 | vector value = { 6,3,5,4,6 }; 76 | int sumValue = 0; 77 | vector result = knasSack(n, c, weight, value); 78 | for (int i = 0; i < result.size(); i++) 79 | { 80 | if (result[i]) 81 | { 82 | sumValue += value[i]; 83 | } 84 | // 物品选择情况,下标,从0开始 85 | cout << "第" << i << "件物品:" << (result[i] == true ? "选" : "不选") << endl; 86 | } 87 | cout << sumValue << endl; // 总价值 88 | 89 | cout << "Write By JZQ!" << endl; 90 | //自动排版:ctrl+k+F 91 | return 0; 92 | } -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/1.strlen:计算字符串长度.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/1.strlen:计算字符串长度.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/10.strchr:字符串中找首次出现某个字符的字符串.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/10.strchr:字符串中找首次出现某个字符的字符串.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/1元一瓶水,两个瓶子兑换一瓶水,问总共能喝几瓶水.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/1元一瓶水,两个瓶子兑换一瓶水,问总共能喝几瓶水.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/2.strcmp:比较字符串大小.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/2.strcmp:比较字符串大小.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/2020届_笔试面试_C++刷题笔记.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {A10237B7-B1DA-4F84-B832-C702E4B5C924} 24 | Win32Proj 25 | My2020届笔试面试C刷题笔记 26 | 10.0.17763.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v141 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v141 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v141 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v141 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | Disabled 89 | true 90 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 91 | true 92 | 93 | 94 | true 95 | Console 96 | 97 | 98 | 99 | 100 | Level3 101 | Disabled 102 | true 103 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | true 108 | Console 109 | 110 | 111 | 112 | 113 | Level3 114 | MaxSpeed 115 | true 116 | true 117 | true 118 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 119 | true 120 | 121 | 122 | true 123 | true 124 | true 125 | Console 126 | 127 | 128 | 129 | 130 | Level3 131 | MaxSpeed 132 | true 133 | true 134 | true 135 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 136 | true 137 | 138 | 139 | true 140 | true 141 | true 142 | Console 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/2020届_笔试面试_C++刷题笔记.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {e9a4264c-bfab-490b-ad68-e14f0ff7fa82} 6 | 7 | 8 | {b3f2b9e0-29a5-4bc9-ab08-ba6916cb8964} 9 | 10 | 11 | {8812b659-b60a-4e72-a132-cb7cfcd26924} 12 | 13 | 14 | {972d9446-d65b-4187-958b-58fc8529cfa9} 15 | 16 | 17 | {eaa21513-daab-4171-b795-c852df2491fb} 18 | 19 | 20 | {19afc58e-2abf-4e87-812a-4ae73427c1fb} 21 | 22 | 23 | {45bb8ba3-03e0-4dd2-9b80-2220fb5e3915} 24 | 25 | 26 | {02248759-738e-4a20-9c1a-e91dc03e9c4a} 27 | 28 | 29 | {09fae2c8-4f1b-46e6-b0ef-a172e6e2f376} 30 | 31 | 32 | {ed7220ef-dd8a-465d-afc1-2394b0ea80e0} 33 | 34 | 35 | {bdebad9b-fa0e-4a5e-910f-961043f9b49f} 36 | 37 | 38 | {ad12973c-e922-4dc3-b165-74d5602c7f58} 39 | 40 | 41 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 42 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 43 | 44 | 45 | {869ad88d-6839-4927-aba5-4b1649ae7bcc} 46 | 47 | 48 | {4e1a2572-71fd-4d4e-9eec-58648d74a062} 49 | 50 | 51 | {37b32167-6084-4841-8eb5-197c7419db37} 52 | 53 | 54 | {d30e7064-70b5-4ba1-aa45-1d3d6f0ec195} 55 | 56 | 57 | {c15ce32d-0759-410d-acc4-2b54b6a652a7} 58 | 59 | 60 | {8c6c0143-934c-435c-9d7e-d701bbdd9a99} 61 | 62 | 63 | {845d57b6-fdd0-4fb2-bd48-84ab2860158b} 64 | 65 | 66 | {9ea6978a-0c43-4a8d-957f-e18ad12eafe7} 67 | 68 | 69 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 70 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 71 | 72 | 73 | {e6f892e6-4851-437b-ba67-6a363b044055} 74 | 75 | 76 | {54222884-3e07-46eb-aabd-1ca015f7f9e6} 77 | 78 | 79 | {416dc6f9-9c57-4e15-9647-f76f40027e10} 80 | 81 | 82 | {e15b923a-6689-4538-b69a-c914e88e73db} 83 | 84 | 85 | {12cbde50-f318-4530-8ed9-3bb0b99ff51d} 86 | 87 | 88 | 89 | 90 | 栈和队列 91 | 92 | 93 | 栈和队列 94 | 95 | 96 | 栈和队列 97 | 98 | 99 | 栈和队列 100 | 101 | 102 | 栈和队列 103 | 104 | 105 | 栈和队列 106 | 107 | 108 | 栈和队列 109 | 110 | 111 | 面试题__链表 112 | 113 | 114 | 面试题__链表 115 | 116 | 117 | 面试题__链表 118 | 119 | 120 | 面试题__链表 121 | 122 | 123 | 面试题__链表 124 | 125 | 126 | 面试题__常用排序算法 127 | 128 | 129 | 面试题__常用排序算法 130 | 131 | 132 | 面试题__常用排序算法 133 | 134 | 135 | 面试题__常用排序算法 136 | 137 | 138 | 面试题__常用排序算法 139 | 140 | 141 | 面试题__常用排序算法 142 | 143 | 144 | 面试题__常用排序算法 145 | 146 | 147 | 面试题__常用排序算法 148 | 149 | 150 | 面试题__常用排序算法 151 | 152 | 153 | 面试题__常用排序算法 154 | 155 | 156 | 面试题__常用排序算法 157 | 158 | 159 | 面试题__常用排序算法 160 | 161 | 162 | 面试题__常用排序算法 163 | 164 | 165 | 面试题__常用排序算法 166 | 167 | 168 | 169 | 170 | 171 | STL 172 | 173 | 174 | STL 175 | 176 | 177 | STL 178 | 179 | 180 | STL 181 | 182 | 183 | STL 184 | 185 | 186 | STL 187 | 188 | 189 | STL 190 | 191 | 192 | STL 193 | 194 | 195 | STL 196 | 197 | 198 | STL 199 | 200 | 201 | STL 202 | 203 | 204 | 面试题__链表 205 | 206 | 207 | 面试题__链表 208 | 209 | 210 | 笔试题__趋势科技 211 | 212 | 213 | 笔试题__趋势科技 214 | 215 | 216 | 笔试题__拼多多 217 | 218 | 219 | 笔试题__字节跳动 220 | 221 | 222 | 笔试题__字节跳动 223 | 224 | 225 | 笔试题__字节跳动 226 | 227 | 228 | 笔试题__字节跳动 229 | 230 | 231 | 笔试题__字节跳动 232 | 233 | 234 | 235 | 236 | 237 | 笔试题__360 238 | 239 | 240 | 笔试题__360 241 | 242 | 243 | 笔试题__360 244 | 245 | 246 | 笔试题__360 247 | 248 | 249 | 笔试题__360 250 | 251 | 252 | 笔试题__360 253 | 254 | 255 | 笔试题__360 256 | 257 | 258 | 笔试题__360 259 | 260 | 261 | 笔试题__360 262 | 263 | 264 | 笔试题__360 265 | 266 | 267 | STL 268 | 269 | 270 | 笔试题__字节跳动 271 | 272 | 273 | 笔试题__Zoom 274 | 275 | 276 | 笔试题__浦发__面试机试 277 | 278 | 279 | 笔试题__浦发__面试机试 280 | 281 | 282 | 笔试题__华为机试 283 | 284 | 285 | 笔试题__华为机试 286 | 287 | 288 | 面试题__剑指Offer 289 | 290 | 291 | 面试题__剑指Offer 292 | 293 | 294 | 面试题__剑指Offer 295 | 296 | 297 | 面试题__剑指Offer 298 | 299 | 300 | 笔试题__京东 301 | 302 | 303 | 笔试题__京东 304 | 305 | 306 | 笔试题__京东 307 | 308 | 309 | 笔试题__京东 310 | 311 | 312 | 笔试题__京东 313 | 314 | 315 | 笔试题__京东 316 | 317 | 318 | 笔试题__华为机试 319 | 320 | 321 | 笔试题__华为机试 322 | 323 | 324 | 笔试题__华为机试 325 | 326 | 327 | 其他__算法题目 328 | 329 | 330 | 其他__算法题目 331 | 332 | 333 | 其他__算法题目 334 | 335 | 336 | 其他__算法题目 337 | 338 | 339 | 其他__算法题目 340 | 341 | 342 | 其他__算法题目 343 | 344 | 345 | 其他__算法题目 346 | 347 | 348 | 面试题__C语言_字符串_常用函数实现 349 | 350 | 351 | 面试题__C语言_字符串_常用函数实现 352 | 353 | 354 | 面试题__C语言_字符串_常用函数实现 355 | 356 | 357 | 字符串和数组 358 | 359 | 360 | 字符串和数组 361 | 362 | 363 | 字符串和数组 364 | 365 | 366 | 字符串和数组 367 | 368 | 369 | 字符串和数组 370 | 371 | 372 | 字符串和数组 373 | 374 | 375 | 字符串和数组 376 | 377 | 378 | 字符串和数组 379 | 380 | 381 | 面试题__C语言_字符串_常用函数实现 382 | 383 | 384 | 笔试题__汇顶科技 385 | 386 | 387 | 面试题__C语言_字符串_常用函数实现 388 | 389 | 390 | 面试题__C语言_字符串_常用函数实现 391 | 392 | 393 | 面试题__C语言_字符串_常用函数实现 394 | 395 | 396 | 面试题__C语言_字符串_常用函数实现 397 | 398 | 399 | 其他__算法题目 400 | 401 | 402 | 其他__算法题目 403 | 404 | 405 | 笔试题__中兴 406 | 407 | 408 | 笔试题__中兴 409 | 410 | 411 | 其他__算法题目 412 | 413 | 414 | 其他__算法题目 415 | 416 | 417 | 笔试题__中兴 418 | 419 | 420 | 面试题__C语言_字符串_常用函数实现 421 | 422 | 423 | 面试题__C语言_字符串_常用函数实现 424 | 425 | 426 | 笔试题__顺丰科技 427 | 428 | 429 | 笔试题__顺丰科技 430 | 431 | 432 | 笔试题__拼多多 433 | 434 | 435 | 笔试题__拼多多 436 | 437 | 438 | 笔试题__拼多多 439 | 440 | 441 | 笔试题__腾讯 442 | 443 | 444 | 笔试题__腾讯 445 | 446 | 447 | 笔试题__腾讯 448 | 449 | 450 | 笔试题__腾讯 451 | 452 | 453 | 面试题__剑指Offer 454 | 455 | 456 | 面试题__剑指Offer 457 | 458 | 459 | 面试题__剑指Offer 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 其他__算法题目 472 | 473 | 474 | 其他__算法题目 475 | 476 | 477 | 面试题__链表 478 | 479 | 480 | 笔试题__小米 481 | 482 | 483 | 笔试题__小米 484 | 485 | 486 | 笔试题__小米 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 笔试题__网易互娱 496 | 497 | 498 | 笔试题__网易互娱 499 | 500 | 501 | 笔试题__网易互娱 502 | 503 | 504 | 笔试题__爱奇艺 505 | 506 | 507 | 笔试题__爱奇艺 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 笔试题__BIGO 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 面试题__常用排序算法\头文件 525 | 526 | 527 | 面试题__常用排序算法\头文件 528 | 529 | 530 | 面试题__常用排序算法\头文件 531 | 532 | 533 | 面试题__常用排序算法\头文件 534 | 535 | 536 | 面试题__常用排序算法\头文件 537 | 538 | 539 | 面试题__常用排序算法\头文件 540 | 541 | 542 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/3.strcpy:用于字符串复制(复制包含0).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/3.strcpy:用于字符串复制(复制包含0).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/4.strstr:寻找母串中是否存在某个子串.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/4.strstr:寻找母串中是否存在某个子串.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/5.itoa:整数转字符串.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/5.itoa:整数转字符串.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/6.atoi:字符串转整数(遇到非数字字符结束).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/6.atoi:字符串转整数(遇到非数字字符结束).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/7.memcpy:拷贝某段内存.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/7.memcpy:拷贝某段内存.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/8.memset:对指定内存每个字节赋某个值.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/8.memset:对指定内存每个字节赋某个值.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/9.strcat:字符串连接.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/9.strcat:字符串连接.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/Base64加密.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/Base64加密.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/LCS_最长公共子序列.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/LCS_最长公共子序列.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/LIS_最长上升子序列.cpp: -------------------------------------------------------------------------------- 1 | /*************************************** 2 | 【题目】: 3 | 有一个长为n的数列a0, a1, ......, a(n-1)。请求出这个序列中最长的上升子序列的长度。 4 | 上升子序列指的是对于任意的i=(N + 1)/2 ,让你找出这个数M。 29 | Sample Input: 30 | 5 31 | 1 3 2 3 3 32 | Sample Output: 33 | 3 34 | 按照DP的思想,把这个大问题先分解成若干个小问题。所以呢当N为N时,至少有(N + 1)/ 2个M,另外的数就先不管他; 35 | ......然后当N为5得时候,依据题意那么一定至少有3个M,另外两个数就先不管他; 36 | 当N为3的时候,根据题意得,一定有2个数为M,另外一个数就先不管他; 37 | 当N为1的时候,那么这个数一定是M。 38 | 所以就可以把这个序列中得两个不同的数删去(只要有两个数不同就删去),最后剩下的一定是M; 39 | 即,M这个数出现的 次数 >=(N + 1)的一半,所以每次删除两个不同的数,剩下的一定是一个或两个数,一定是M。 40 | 举个栗子:  41 | intput: 9 42 |         3 6 9 3 3 3 8 6 3 43 | loc :  1 2 3 4 5 6 7 8 9 44 | 1、2位置删去 3、4位置删去 6、7位置删去 8、9位置删去,,还剩一个5位置,那么5位置的 3 就是要找的M . 45 | 46 | 47 | ***************************************/ 48 | 49 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/LeetCode520_检测大写字母.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | /*************************************** 9 | 【题目】: 10 | 给定一个单词,你需要判断单词的大写使用是否正确。 11 | 我们定义,在以下情况时,单词的大写用法是正确的: 12 | 全部字母都是大写,比如"USA"。 13 | 单词中所有字母都不是大写,比如"leetcode"。 14 | 如果单词不只含有一个字母,只有首字母大写, 比如 "Google"。 15 | 否则,我们定义这个单词没有正确使用大写字母。 16 | 17 | 示例 1: 18 | 输入: "USA" 19 | 输出: True 20 | 示例 2: 21 | 输入: "FlaG" 22 | 输出: False 23 | 【思路】: 24 | isupper()、islower():用于判断字符是否是大小写。 25 | ***************************************/ 26 | 27 | static bool detectCapitalUse(const string &str) 28 | { 29 | if (str.size() == 0) 30 | { 31 | return false; 32 | } 33 | 34 | int count = 0; 35 | for (int i = 0; i < str.size(); i++) 36 | { 37 | if (isupper(str[i])) // if (word.charAt(i) <= 'Z' && word.charAt(i) >= 'A') 38 | { 39 | count++; 40 | } 41 | } 42 | 43 | if (count == str.size() || (count == 1 && isupper(str[0])) || count == 0) 44 | { 45 | return true; 46 | } 47 | return false; 48 | } 49 | 50 | int main_LeetCode520_检测大写字母(void) 51 | { 52 | string input = "AASDAF"; 53 | cin >> input; 54 | cout << (true == detectCapitalUse(input) ? "true" : "false") << endl; 55 | 56 | cout<<"Write By JZQ!"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | /* 9 | 请听题:给定N(可选作为埋伏点的建筑物数)、D(相距最远的两名特工间的距离的最大值)以及可选建筑的坐标,计算在这次行动中,大锤的小队有多少种埋伏选择。 10 | 注意: 11 | 1. 两个特工不能埋伏在同一地点 12 | 2. 三个特工是等价的:即同样的位置组合(A, B, C) 只算一种埋伏方法,不能因“特工之间互换位置”而重复使用 13 | 14 | 输入描述: 15 | 第一行包含空格分隔的两个数字 N和D(1 ≤ N ≤ 1000000; 1 ≤ D ≤ 1000000) 16 | 第二行包含N个建筑物的的位置,每个位置用一个整数(取值区间为[0, 1000000])表示,从小到大排列(将字节跳动大街看做一条数轴) 17 | 18 | 输出描述: 19 | 一个数字,表示不同埋伏方案的数量。结果可能溢出,请对 99997867 取模 20 | 21 | 输入例子1: 22 | 4 3 23 | 1 2 3 4 24 | 25 | 输出例子1: 26 | 4 27 | 28 | 例子说明1: 29 | 可选方案 (1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4) 30 | 31 | 输入例子2: 32 | 5 19 33 | 1 10 20 30 50 34 | 35 | 输出例子2: 36 | 1 37 | 38 | 例子说明2: 39 | 可选方案 (1, 10, 20) 40 | */ 41 | 42 | // 计算组合数C(n,2)的数目 43 | long long Cn2(long long n) { 44 | return (n - 1) * n / 2; 45 | } 46 | 47 | static void function(vector &v, const long long n, const long long d) 48 | { 49 | long long count = 0; 50 | for (int i = 0, j = 0; i < n; i++) 51 | { 52 | //cin >> v[i]; 53 | while (i >= 2 && (v[i] - v[j]) > d) // i是从0开始的,i >= 2,代表需要有0 1 2 共三个组合长度,即m = 3。 54 | { // (v[i] - v[j]) > d,是本题所要求的,距离不超过d. 55 | j++; 56 | } 57 | count += Cn2(i - j); // 相当于每次固定开头那个数,从剩下的数里取对应个数的组合数。 58 | } 59 | cout << count % 99997867 << endl; 60 | } 61 | 62 | int main12165125168431684128643164831516(void) 63 | { 64 | long long n = 4, d = 3; 65 | vector array = { 1, 2, 3, 4 }; 66 | function(array, n, d); 67 | 68 | 69 | cout<<"Write By JZQ!"< 4 | void BubbleSort(T * array, const int len); 5 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/删除字符串中出现次数最少的字符.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/删除字符串中出现次数最少的字符.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/判断一个链表是否为回文结构.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | /* 8 | 题目:判断一个链表是否为回文结构。 9 | 要求:时间复杂度为 O(n),空间时间复杂度为O(1)。 10 | 若没有上诉要求,直接先将链表节点值以次压入栈中,再以次弹出比对,即可完成。 11 | 12 | 思路分析:回文链表的特点就是对称,那么要判断是否回文,就可以用两个指针指向对称的节点, 13 | 看它们的数据是否一样。由于是单向链表,不能同时用两个指针,从头尾向内部遍历取值比较。 14 | 且本题对空间复杂度也有要求,所以可用如下方法实现。 15 | 16 | 具体步骤如下: 17 | (1)先得到链表的中间节点; 18 | (2)从中间节点的下一个节点开始,反转链表。 19 | (3)从中间节点处,断开原链表。 20 | (4)用两个指针分别向两个端点移动,同时进行比较,数据相同则继续,数据不同则直接返回false。直到遍历完成,最后返回true。 21 | (5)最后将后半部分逆序复原 22 | */ 23 | 24 | static struct Node 25 | { 26 | int data; 27 | Node *next; 28 | }; 29 | 30 | // 打印不带头节点的单链表 31 | static void printList(Node *head) 32 | { 33 | while (head != nullptr) 34 | { 35 | cout << head->data << ' '; 36 | head = head->next; 37 | } 38 | cout << endl; 39 | } 40 | 41 | static Node * creatList() // 创建单链表(不带头节点的单链表),new出来的控件不能用引用返回。会造成内存泄漏 42 | { 43 | Node *head = nullptr; 44 | Node *ptr = nullptr; 45 | for (int i = 0; i < 5; i++) 46 | { 47 | if (nullptr == head) // 这里是为了保持head1停留在第一个节点不动,让辅助指针ptr移动。 48 | { 49 | head = new Node; 50 | head->data = i; 51 | head->next = nullptr; 52 | ptr = head; 53 | continue; 54 | } 55 | ptr->next = new Node; 56 | ptr = ptr->next; 57 | ptr->data = i; 58 | ptr->next = nullptr; 59 | } 60 | for (int i = 4; i >= 0; --i) 61 | { 62 | ptr->next = new Node; 63 | ptr = ptr->next; 64 | ptr->data = i; 65 | ptr->next = nullptr; 66 | } 67 | return head; 68 | } 69 | 70 | // 快慢指针查找单链表的中间节点(不带头节点的单链表) 71 | static Node *FindMid(Node *head) 72 | { 73 | Node *slow = head; //初始时快、慢指针都指向第一个节点。 74 | Node *fast = head; 75 | 76 | while (fast != nullptr && fast->next != nullptr && fast->next->next != nullptr) 77 | { 78 | fast = fast->next->next; 79 | slow = slow->next; 80 | } 81 | 82 | return slow; // 若链表节点为奇数个,slow为中间,若为偶数个slow为中间两个的前面那个。 83 | } 84 | 85 | // 从中间节点反转链表(不带头节点的单链表) 86 | static Node *reverseList(Node *mid) 87 | { 88 | Node *cur = mid; 89 | Node *pre = nullptr; 90 | Node *next = cur->next; 91 | while (nullptr != cur) 92 | { 93 | next = cur->next; 94 | cur->next = pre; 95 | pre = cur; 96 | cur = next; 97 | } 98 | 99 | return pre; // 返回反转后的头结点(原链表的最后一个节点) 100 | } 101 | 102 | // 回文(指顺读和倒读都一样的词语) 103 | static bool isPalindrome(Node *Head , Node *rHead) 104 | { 105 | Node *start = Head; 106 | Node *end = rHead; 107 | while (start != nullptr && end != nullptr) 108 | { 109 | if (start->data == end->data) // start、end有一个到中点的null即结束循环,所以不用判断时候是奇数、偶数个节点 110 | { 111 | start = start->next; 112 | end = end->next; 113 | } 114 | else 115 | return false; 116 | } 117 | return true; 118 | } 119 | 120 | // 复原链表(不带头节点的单链表) 121 | static void recoverList(Node *rHead) 122 | { 123 | Node *pre = nullptr; 124 | Node *cur = rHead; 125 | Node *next = cur->next; 126 | while (cur != nullptr) 127 | { 128 | next = cur->next; 129 | cur->next = pre; 130 | pre = cur; 131 | cur = next; 132 | } 133 | } 134 | 135 | int main151412543452415145(void) 136 | { 137 | Node *Head = nullptr; 138 | Head = creatList(); 139 | 140 | printList(Head); 141 | 142 | Node *mid = nullptr; 143 | mid = FindMid(Head); 144 | 145 | Node *rHead = nullptr; 146 | rHead = reverseList(mid); 147 | 148 | if (isPalindrome(Head, rHead)) 149 | { 150 | cout << "是回文!" << endl; 151 | } 152 | else 153 | { 154 | cout << "不是回文!" << endl; 155 | } 156 | 157 | recoverList(rHead); 158 | cout << "复原后:" << endl; 159 | printList(Head); 160 | 161 | cout<<"Write By JZQ!"< 4 | void ShellSort(T *array, int len); 5 | 6 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/常用排序算法复习测试.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/常用排序算法复习测试.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/归并算法排序.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/归并算法排序.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/归并算法排序.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | template 3 | void MergeSort(T *array, int len); 4 | 5 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/快速排序算法.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/快速排序算法.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/快速排序算法.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | void Quicksort(T *array, int low, int high); 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/打印两个有序链表的公共部分.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/打印两个有序链表的公共部分.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/找出字符串中第一个不重复的字符.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/找出字符串中第一个不重复的字符.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/找老乡(并查集).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | /* 7 | 看博客《https://blog.csdn.net/qq_41593380/article/details/81146850》 8 | 并查集,顾名思义,一个实现了合并和查询集合方法的数据结构。最常见的方式是用数组来实现。 9 | 并查集的最终目的是将输入的节点按照其连接关系,分割成一个或多个子集。 10 | 一个简单的应用就是判断无向图的连通分量个数,或者判断无向图中任何两个顶点是否连通。 11 | 例如,节点 ① ② ③ ④,已知 ① 与 ② 相连, ② 与 ④ 相连,经过并查集操作, 12 | 应该形成两个集合,其中一个集合是 {① ② ④},另一个是 {③}。 13 | 14 | 大学的同学来自全国各地,对于远离家乡步入陌生大学校园的大一新生来说,碰到老乡是多么激动的一件事, 15 | 于是大家都热衷于问身边的同学是否与自己同乡,来自新疆的小赛尤其热衷。但是大家都不告诉小赛他们来自哪里, 16 | 只是说与谁同乡,从所给的信息中,你能告诉小赛有多少人确定是她的同乡吗? 17 | 18 | 输入 19 | 每个测试实例首先包括2个整数,N(1 <= N <= 1000),M(0 <= M <= N*(N-1)/2),代表现有N个人(用1~N编号)和M组关系; 20 | 在接下来的M行里,每行包括3个整数,a,b, c,如果c为1,则代表a跟b是同乡;如果c为0,则代表a跟b不是同乡; 21 | 当N = 0,M = 0输入结束; 22 | 已知1表示小赛本人。 23 | 24 | 输入样例: 25 | 3 1 26 | 2 3 1 27 | 28 | 5 4 29 | 1 2 1 30 | 3 4 0 31 | 2 5 1 32 | 3 2 1 33 | 输出样例: 34 | 0 35 | 3 36 | 【思路】:其实就是找含有1的并查集 37 | */ 38 | 39 | // 递归查找x的根节点,findSet是并查集 40 | static int find(vector& findSet, int x) 41 | { 42 | return findSet[x] == x ? x : find(findSet, findSet[x]); 43 | } 44 | 45 | // 两个点连通但根节点却不同,需要进行连接 46 | static void join(vector& findSet, int x, int y) 47 | { 48 | int root1 = find(findSet, x); 49 | int root2 = find(findSet, y); 50 | if (root1 != root2) 51 | { 52 | findSet[root1] = root2; 53 | } 54 | } 55 | 56 | int main112653612456821645824562814658845696458(void) 57 | { 58 | int N, M; 59 | while (cin >> N >> M) 60 | { 61 | if (N == 0 && M == 0) // 当N = 0,M = 0输入结束; 62 | { 63 | break; 64 | } 65 | // 初始化 N 个独立子集合,初始化并查集 66 | vector findSet(N + 1, 0); 67 | for (int i = 1; i <= N; i++) 68 | { 69 | findSet[i] = i; // 从0开始。0位置不使用。 70 | } 71 | // 链接x、y两个节点 72 | int a, b, c; 73 | while (M--) 74 | { 75 | cin >> a >> b >> c; 76 | if (c == 1) // 本题,要求c = 1时,链接a,b。 77 | { 78 | join(findSet, a, b); // 每合并一次,并查集findSet的子集就少一。 79 | } 80 | } 81 | // 找到小赛(1)在并查集中的代表 82 | int k = find(findSet, 1); 83 | // 计数:计算以k为代表的元素个数 84 | int count = 0; 85 | for (int i = 1; i <= N; i++) 86 | { 87 | if (k == find(findSet, i)) 88 | { 89 | count++; 90 | } 91 | } 92 | 93 | cout << count - 1 << endl; // 找到小赛(1)的老乡个数,要把自己在并查集中的计数减去。 94 | 95 | 96 | //set r; 97 | //// 计算根节点个数,即计算并查集中有多少个子集 98 | //for (int i = 1; i <= N; i++) 99 | //{ 100 | // r.insert(find(findSet, findSet[i])); 101 | //} 102 | 103 | //return r.size(); 104 | } 105 | 106 | return 0; 107 | } -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/找质数__第二题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/找质数__第二题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/报文转义__第一题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/报文转义__第一题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/排列组合问题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/排列组合问题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/排序(只能是0位置与某个位置交换).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/排序(只能是0位置与某个位置交换).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/插入法排序.cpp: -------------------------------------------------------------------------------- 1 | #include "插入法排序.h" 2 | 3 | //时间复杂度: n² 4 | /* 5 | //在排序之前我们需要搞清一个思路,新插入一个数据的时候,排序过后的数组都是 6 | //从小到大排列好的,所以我们需要从后往前查找,直到找到比我们要插入的数字还小的 7 | //值。这个时候我们需要一个变量j作为标识 8 | */ 9 | 10 | 11 | 12 | template 13 | void InsertSort(T * array, const int len) 14 | { 15 | for (int i = 1; i < len; ++i) 16 | { 17 | for (int j = i - 1; j >= 0; --j) 18 | { 19 | if (array[j] > array[j + 1]) 20 | { 21 | array[j] = array[j] ^ array[j + 1]; 22 | array[j + 1] = array[j] ^ array[j + 1]; 23 | array[j] = array[j] ^ array[j + 1]; 24 | } 25 | } 26 | } 27 | } 28 | 29 | 30 | /* 31 | template 32 | void InsertSort(T * array, const int len) 33 | { 34 | T temp = 0; 35 | for (int i = 1; i < len; i++)//还是n-1趟,只是这里从1开始,即第二个元素开始,前面的是有序的。 36 | { 37 | temp = array[i];//取出这个要和前面有序序列比较的元素。 38 | int j = 0; 39 | for (j = i - 1;j >= 0;j--)//这个元素的和前面有序序列比较,直到下标0 40 | { 41 | if (array[j] > temp)//将大于temp的数向后移动 42 | { 43 | array[j + 1] = array[j]; 44 | } 45 | else 46 | { 47 | break;//不再比temp大了,就不移动了 48 | } 49 | } 50 | //移动完,就插入元素 51 | array[j + 1] = temp;//这里,因为j--,跳出循环时,j多减了一次 52 | } 53 | } 54 | */ 55 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/插入法排序.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | void InsertSort(T * array, const int len); 5 | 6 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/数学期望.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/数学期望.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/数组排序后,相邻两数的最大差值.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/数组排序后,相邻两数的最大差值.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/整数取偶数位上的数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/整数取偶数位上的数.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/斐波那契数列.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/斐波那契数列.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/旋转数组的最小数字.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/旋转数组的最小数字.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/旋转正方形矩阵.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/旋转正方形矩阵.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/最长子序列(特殊).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | static void findMaxSubstr(vector &nums, const int len) 6 | { 7 | int maxL = 0; 8 | vector temp(len, 0); 9 | for (int i = 0; i < len; i++) 10 | { 11 | int L = 0; 12 | int R = maxL; 13 | while (L < R) 14 | { 15 | int mid = L + (R - L) / 2; 16 | if (temp[mid] <= nums[i]) 17 | { 18 | L = mid + 1; 19 | } 20 | else 21 | { 22 | R = mid; 23 | } 24 | } 25 | 26 | temp[L] = nums[i]; 27 | if (L == maxL) 28 | { 29 | maxL++; 30 | } 31 | } 32 | cout << maxL << endl; 33 | } 34 | 35 | int main____dsad52(void) 36 | { 37 | int len = 0; 38 | while (cin >> len) 39 | { 40 | vector nums(len, 0); 41 | for (int i = 0; i < len; i++) 42 | { 43 | cin >> nums[i]; 44 | } 45 | findMaxSubstr(nums, len); 46 | } 47 | return 0; 48 | } -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/栈.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/栈.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/栈_实现_队列.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/栈_实现_队列.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/栈(固定大小数组实现).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/栈(固定大小数组实现).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/桶排序(计数排序).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/桶排序(计数排序).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源1-1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源1-1.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源1-2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源1-2.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源1.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源10.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源10.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源11.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //using namespace std; 3 | // 4 | //int function(int a) 5 | //{ 6 | // if (a == 1 || a == 0) 7 | // { 8 | // return 1; 9 | // } 10 | // if (a < 1) 11 | // { 12 | // return 0; 13 | // } 14 | // if (a == 2) 15 | // { 16 | // return 2; 17 | // } 18 | // return function(a - 1) + function(a - 2) + function(a - 3); 19 | //} 20 | // 21 | //int main(void) 22 | //{ 23 | // int n = 0; 24 | // while (cin >> n) 25 | // { 26 | // cout << function(n) << endl; 27 | // } 28 | // return 0; 29 | //} -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源12.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源12.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源13.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | //#include 4 | //#include 5 | //using namespace std; 6 | // 7 | //static int search(vector &array, int size, int target, int flag) 8 | //{ 9 | // int left = 0, right = size - 1; 10 | // int mid = 0, last = -1; 11 | // while (left <= right) 12 | // { 13 | // mid = (left + right) / 2; 14 | // if (array[mid] > target) { 15 | // right = mid - 1; 16 | // } 17 | // else if (array[mid] < target) { 18 | // left = mid + 1; 19 | // } 20 | // else { 21 | // last = mid; 22 | // if (flag == 0) {//找第一个值等于target的索引 23 | // //在左边继续查找 24 | // right = mid - 1; 25 | // } 26 | // else if (flag == 1) {//找最后一个值等于target的索引 27 | // //在右边继续查找 28 | // left = mid + 1; 29 | // } 30 | // } 31 | // } 32 | // return last; 33 | //} 34 | //static int function(vector &array, int num) 35 | //{ 36 | // int len = array.size(); 37 | // int first = search(array, len, num, 0); 38 | // int last = search(array, len, num, 1); 39 | // if (first == -1) { 40 | // return 0; 41 | // } 42 | // return last - first + 1; 43 | //} 44 | //int main(void) 45 | //{ 46 | // vector a= { 1,2,3,3,3,3,4,5 }; 47 | // int num = 3; 48 | // 49 | // cout << function(a, num) << endl; 50 | // 51 | // return 0; 52 | //} -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源14.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | //#include 4 | //#include 5 | //using namespace std; 6 | // 7 | //static string function(string str, int k) 8 | //{ 9 | // for (int start = 0; start < str.size(); start += 2 * k) 10 | // { 11 | // int i = start; 12 | // int j = min(start + k - 1, (int)str.size() - 1); 13 | // for (; i < j; i++, j--) 14 | // { 15 | // swap(str[i], str[j]); 16 | // } 17 | // } 18 | // return str; 19 | //} 20 | // 21 | //int main(void) 22 | //{ 23 | // string str = "ab"; 24 | // int num = 3; 25 | // 26 | // cout << function(str, num) << endl; 27 | // 28 | // return 0; 29 | //} -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源15.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源15.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源16.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源16.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源2-1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源2-1.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源2-2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源2-2.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源2.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源3-1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源3-1.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源3-2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源3-2.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源3.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | // 3 | //#include 4 | //#include 5 | //using namespace std; 6 | // 7 | //bool compare(int a, int b) 8 | //{ 9 | // return a > b; 10 | //} 11 | // 12 | //int main(void) 13 | //{ 14 | // int n, m, k; 15 | // while (cin >> n >> m >> k) 16 | // { 17 | // vector arr; 18 | // for (int i = 0; i < n; ++i) 19 | // { 20 | // for (int j = 0; j < m; ++j) 21 | // { 22 | // arr.push_back((i + 1)*(j + 1)); 23 | // } 24 | // } 25 | // sort(arr.begin(), arr.end(), compare); 26 | // cout << arr[k - 1] << endl; 27 | // } 28 | // return 0; 29 | //} -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源4.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源4.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源5.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源5.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源6.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | //#include 4 | //using namespace std; 5 | // 6 | //static bool compare_desc(int a, int b) 7 | //{ 8 | // return a > b; 9 | //} 10 | //static bool compare_inc(int a, int b) 11 | //{ 12 | // return a < b; 13 | //} 14 | // 15 | //int main(void) 16 | //{ 17 | // int n; 18 | // while (cin >> n) 19 | // { 20 | // vector arr_ai(n); 21 | // vector arr_bi(n); 22 | // for (int i = 0; i < n; i++) 23 | // { 24 | // cin >> arr_ai[i]; 25 | // cin >> arr_bi[i]; 26 | // } 27 | // 28 | // sort(arr_ai.begin(), arr_ai.end(), compare_desc); 29 | // sort(arr_bi.begin(), arr_bi.end(), compare_inc); 30 | // 31 | // int result = 0; 32 | // for (int i = 0; i < n; i++) 33 | // { 34 | // result += arr_ai[i] * i + arr_bi[i] * (n - i - 1); 35 | // } 36 | // cout << result << endl; 37 | // } 38 | // 39 | // return 0; 40 | //} -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源7.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | //#include 4 | //using namespace std; 5 | // 6 | //static void swap(int &a, int &b) 7 | //{ 8 | // int temp = a; 9 | // a = b; 10 | // b = temp; 11 | //} 12 | // 13 | //static int function(vector &vec, int k, int s, int e) 14 | //{ 15 | // int roll = vec[s], be = 0, j = s; 16 | // for (int i = s + 1; i <= e; i++) 17 | // { 18 | // if (vec[i] < roll) 19 | // { 20 | // j++; 21 | // swap(vec[i], vec[j]); 22 | // be++; 23 | // } 24 | // } 25 | // 26 | // swap(vec[s], vec[j]); 27 | // if (be == k - 1) 28 | // { 29 | // return roll; 30 | // } 31 | // else if (be < k - 1) 32 | // { 33 | // return function(vec, k - be - 1, j + 1, e); 34 | // } 35 | // else 36 | // { 37 | // return function(vec, k, s, j - 1); 38 | // } 39 | //} 40 | // 41 | //int main(void) 42 | //{ 43 | // int n = 0; 44 | // long long k = 0; 45 | // while (cin >> n >> k) 46 | // { 47 | // vector partA(n, 0); 48 | // vector partB(n, 0); 49 | // vector keys; 50 | // for (int i = 0; i < n; i++) 51 | // { 52 | // cin >> partA[i]; 53 | // } 54 | // for (int i = 0; i < n; i++) 55 | // { 56 | // cin >> partB[i]; 57 | // } 58 | // for (int i = 0; i < n; i++) 59 | // { 60 | // for (int j = 0; j < n; j++) 61 | // { 62 | // if (find(keys.begin(), keys.end(), partA[j] * partB[i]) == keys.end()) 63 | // { 64 | // keys.push_back(partA[j] * partB[i]); 65 | // } 66 | // } 67 | // } 68 | // 69 | // cout << function(keys, k, 0, keys.size() - 1); 70 | // } 71 | // 72 | // return 0; 73 | //} -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源8.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源8.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/源9.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/源9.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/猫狗队列问题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/猫狗队列问题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/用两个栈实现队列.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/用两个栈实现队列.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/笔试题__Zoom.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/笔试题__Zoom.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/网易互娱__第一题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/网易互娱__第一题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/网易互娱__第三题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/网易互娱__第三题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/网易互娱__第二题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/网易互娱__第二题.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/荷兰国国旗问题(快排的partition过程).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/荷兰国国旗问题(快排的partition过程).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/裂变反应堆(组合的应用法).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/裂变反应堆(组合的应用法).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/裂变反应堆(背包问题升级_多个限制条件的背包问题).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/裂变反应堆(背包问题升级_多个限制条件的背包问题).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/谓词的写法.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/谓词的写法.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/转圈打印矩阵.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/转圈打印矩阵.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/逆序对问题(左边数比右边数大,则这两个数构成一个逆序对).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/逆序对问题(左边数比右边数大,则这两个数构成一个逆序对).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/选择法排序.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/选择法排序.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/选择法排序.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | void SelectSort(T *array, const int len); 5 | -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/通讯软件__第三题(并查集).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/通讯软件__第三题(并查集).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/重建二叉树(前序+中序的值).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/重建二叉树(前序+中序的值).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/重建二叉树(序列化与反序列化).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/重建二叉树(序列化与反序列化).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/链表的成对反转.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/链表的成对反转.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/键入个数_一维数组.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/键入个数_一维数组.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/键入个数_二维数组.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/键入个数_二维数组.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/队列_实现_栈.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/队列_实现_栈.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/队列(固定大小数组实现).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/队列(固定大小数组实现).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/面试题3__数组中重复的数字.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/面试题3__数组中重复的数字.cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/面试题4__二维数组中的查找(有序的二维数组).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/面试题4__二维数组中的查找(有序的二维数组).cpp -------------------------------------------------------------------------------- /2020届_笔试面试_C++刷题笔记/面试题5__替换空格(字符串查找和替换).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeanLife/2020th_WriteAndInterview_C-_Notes/6ce407a66a9dfc56f05350cfba614b5bf43db17f/2020届_笔试面试_C++刷题笔记/面试题5__替换空格(字符串查找和替换).cpp --------------------------------------------------------------------------------