上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页
摘要: 1 class Solution { public: bool search(vector<int>& nums, int target) { int index = -1; for (int i = 0; i < nums.size() - 1; ++i){ if (nums[i] > nums[ 阅读全文
posted @ 2023-04-05 14:47 破忒头头 阅读(24) 评论(0) 推荐(0)
摘要: class Solution { public: int mySqrt(int x) { long a = x; while (a * a > x){ a = (a + x / a) / 2; } return a; } }; 阅读全文
posted @ 2023-04-05 11:44 破忒头头 阅读(19) 评论(0) 推荐(0)
摘要: function.h // // Created by gaogaoaixuexi on 2023/4/2. // #ifndef DATASTRUCT_FUNCTION_H #define DATASTRUCT_FUNCTION_H #include <stdio.h> #include <std 阅读全文
posted @ 2023-04-04 00:04 破忒头头 阅读(23) 评论(0) 推荐(0)
摘要: 括号匹配 #include <stdio.h> #include <stdlib.h> #define MaxSize 50 typedef char ElemType; typedef struct{ ElemType data[MaxSize]; int top; }SqStack; void 阅读全文
posted @ 2023-03-26 22:22 破忒头头 阅读(36) 评论(0) 推荐(0)
摘要: class Solution { public: int func(vector<int>& nums,int begin,int end){ while(begin + 1 < end){ int mid = begin + ((end - begin) >>1); if(nums[mid] == 阅读全文
posted @ 2023-02-24 20:25 破忒头头 阅读(24) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; int func(int n){ if(n==0) return 1; if(n==1) return 1; if(n==2) return 2; return func(n-1) + func (n-2) + fun 阅读全文
posted @ 2023-02-14 17:51 破忒头头 阅读(17) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; const int N = 16; bool record[N]; void selection(int start, int end,int capacity,int num) { if(num == capacit 阅读全文
posted @ 2023-02-06 17:34 破忒头头 阅读(13) 评论(0) 推荐(0)
摘要: 回溯 #include <iostream> using namespace std; const int N = 16; bool record[N]; void selection(int start, int end) { if(start>end){ //到达上届 for(int i = 1 阅读全文
posted @ 2023-02-06 17:13 破忒头头 阅读(27) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; /** * 希尔排序 * 希尔排序是插入排序的的改进 * 改进的主要思想是: * 1.插入排序对于小规模数组效率较高 * 2.插入排序对于部分有序数组排序效率高 * 希尔排序的性能取决于递增序列,和h有关。 * 希尔排 阅读全文
posted @ 2023-02-05 18:09 破忒头头 阅读(31) 评论(0) 推荐(0)
摘要: 二分查找 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)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页