-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test #6
Open
voodoozhang
wants to merge
1
commit into
OpenEduTech:main
Choose a base branch
from
voodoozhang:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
test #6
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// | ||
// Created by Pointer Null on 2023/3/20. | ||
// | ||
//给你一个长度为 n 的数组 nums ,该数组由从 1 到 n 的 不同 整数组成。另给你一个正整数 k 。 | ||
// | ||
// 统计并返回 nums 中的 中位数 等于 k 的非空子数组的数目。 | ||
// | ||
// 注意: | ||
// | ||
// | ||
// 数组的中位数是按 递增 顺序排列后位于 中间 的那个元素,如果数组长度为偶数,则中位数是位于中间靠 左 的那个元素。 | ||
// | ||
// | ||
// | ||
// 例如,[2,3,1,4] 的中位数是 2 ,[8,4,3,5,1] 的中位数是 4 。 | ||
// | ||
// | ||
// 子数组是数组中的一个连续部分。 | ||
// | ||
// | ||
// | ||
// | ||
// 示例 1: | ||
// | ||
// | ||
//输入:nums = [3,2,1,4,5], k = 4 | ||
//输出:3 | ||
//解释:中位数等于 4 的子数组有:[4]、[4,5] 和 [1,4,5] 。 | ||
// | ||
// | ||
// 示例 2: | ||
// | ||
// | ||
//输入:nums = [2,3,1], k = 3 | ||
//输出:1 | ||
//解释:[3] 是唯一一个中位数等于 3 的子数组。 | ||
// | ||
// | ||
// | ||
// | ||
// 提示: | ||
// | ||
// | ||
// n == nums.length | ||
// 1 <= n <= 10⁵ | ||
// 1 <= nums[i], k <= n | ||
// nums 中的整数互不相同 | ||
// | ||
// | ||
// Related Topics 数组 哈希表 前缀和 👍 93 👎 0 | ||
|
||
|
||
//leetcode submit region begin(Prohibit modification and deletion) | ||
#include "vector" | ||
#include "map" | ||
using namespace std; | ||
|
||
class Solution { | ||
public: | ||
int find_1(vector<int>arr1,vector<int>arr2,int idx){ | ||
int sum=0; | ||
for (int i = arr2.size()-1; i >=0 ; --i) { | ||
for (int j = 0; j <arr1.size() ; ++j) { | ||
if (arr2[i]>idx&&arr1[j]<idx&&(arr2[i]-arr1[j]-1)%2==0){ | ||
sum++; | ||
} else return sum; | ||
} | ||
} | ||
return sum; | ||
} | ||
int find_0(vector<int>arr,int idx){ | ||
int sum=0; | ||
for (int i = arr.size()-1;i>=0; --i){ | ||
if (arr[i]>idx){ | ||
for (int j = 0; j < i; ++j) { | ||
if (arr[j]<idx){ | ||
if ((arr[i]-arr[j]-1)%2!=0)sum++; | ||
} else break; | ||
} | ||
} else return sum; | ||
} | ||
return sum; | ||
} | ||
int countSubarrays(vector<int>& nums, int k) { | ||
vector<int>count(nums.size()+1,0); | ||
map<int,vector<int>>F; | ||
int index=-1; | ||
for (int i = 0; i < nums.size(); ++i) { | ||
if (nums[i]>k){ | ||
count[i+1]=count[i-1]+1; | ||
} else if (nums[i]<k){ | ||
count[i+1]=count[i-1]-1; | ||
} else { | ||
index=i; | ||
} | ||
F[count[i+1]].push_back(i); | ||
} | ||
for (auto arr:F) { | ||
|
||
} | ||
return 0; | ||
} | ||
}; | ||
//leetcode submit region end(Prohibit modification and deletion) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the code review