Bin search

This commit is contained in:
2022-11-24 16:44:36 +08:00
parent 8f3ebbdd3d
commit 2822593c46
11 changed files with 256 additions and 120 deletions

View File

@@ -2,13 +2,16 @@
#define S0034_FIND_FIRST_AND_LAST_POSITION_OF_ELEMENT_IN_SORTED_ARRAY_HPP
#include <vector>
#include <cmath>
using namespace std;
class Solution {
class Solution1 {
public:
vector<int> searchRange(vector<int>& nums, int target);
};
class Solution2 {
public:
vector<int> searchRange(vector<int>& nums, int target);
};
#endif

View File

@@ -2,11 +2,15 @@
#define S0035_SEARCH_INSERT_POSITION_HPP
#include <vector>
#include <cmath>
using namespace std;
class Solution {
class Solution1 {
public:
int searchInsert(vector<int>& nums, int target);
};
class Solution2 {
public:
int searchInsert(vector<int>& nums, int target);
};

View File

@@ -0,0 +1,18 @@
#ifndef S0704_BINARY_SEARCH_HPP
#define S0704_BINARY_SEARCH_HPP
#include <vector>
using namespace std;
class Solution1 {
public:
int binSearch(vector<int>& nums, int target);
};
class Solution2 {
public:
int binSearch(vector<int>& nums, int target);
};
#endif