摘要: 二分查找 class Solution { public: int search(vector<int>& nums, int target) { // //左闭右闭区间 // int l = 0; // int r = nums.size() - 1; // while(l <= r){ // i 阅读全文
posted @ 2023-02-03 22:07 破忒头头 阅读(10) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; /** * 将前N个圆盘从from搬运到to通过辅助help * @param N * @param from * @param to */ void hanoi(int N, char from, char to, 阅读全文
posted @ 2023-02-03 21:25 破忒头头 阅读(36) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> using namespace std; /** * 插入排序 * 概述:当前i的前面的元素都是有序的,将i索引处的元素插入到前面有序区域合适的位置。 * 时间复杂度:平均情况下,插入排序需要比较(N^2)/4次比较和(N^ 阅读全文
posted @ 2023-02-03 14:21 破忒头头 阅读(39) 评论(0) 推荐(0)