This commit is contained in:
2025-12-05 03:26:44 +08:00
parent affa209d93
commit 0fd446de99
7 changed files with 65 additions and 4 deletions

6
25/11/1015.cpp Normal file
View File

@@ -0,0 +1,6 @@
class Solution {
public:
int smallestRepunitDivByK(int k) {
}
};

33
25/11/3318.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include <vector>
#include <unordered_map>
std::vector<int> findXSum(std::vector<int> &nums, int k, int x)
{
int l = 0;
int r = k - 1;
std::unordered_map<int, int> m;
std::vector<int> ans;
std::vector<std::pair<int,int>> temp;
int count = 0;
for(int i = l;i <= k - 1; ++i){
m[nums[i]] += 1;
}
for(int i = 0;r < nums.size();++i){
if(i != 0){
}
for (const auto& [key, value] : m) {
temp.push_back(std::pair<int,int>(key,value));
}
std::sort(temp.begin(),temp.end(),[](std::pair<int,int> x,std::pair<int,int> y){
return x.second > y.second;
});
for(int i = 0;i < x;i++){
count += temp[i].first * temp[i].second;
}
ans.push_back(count);
temp.clear();
count = 0;
}
return ans;
}

View File

@@ -1,4 +1,4 @@
package D
package L12
func prefixesDivBy5(nums []int) []bool {
ans := make([]bool, len(nums))

View File

@@ -1,4 +1,4 @@
package C
package L12
func kLengthApart(nums []int, k int) bool {
last := -k - 1

View File

@@ -1,4 +1,4 @@
package A
package L12
func minCost(colors string, neededTime []int) int {
count := 0

View File

@@ -1,4 +1,4 @@
package B
package L12
func minOperations(nums []int) int {
n, gcdAll, cnt1 := len(nums), 0, 0

22
25/11/go/3432.go Normal file
View File

@@ -0,0 +1,22 @@
package L12
func countPartitions(nums []int) int {
n := len(nums)
count := 0
prefix := make([]int, n)
for i, v := range nums {
count += v
prefix[i] = count
}
ans := 0
for i, v := range prefix {
if i == n-1 {
break
}
if (count-2*v)%2 == 0 {
ans++
}
}
return ans
}