From 124c7332d809d12102f519a9fdbbe743ac8b916c Mon Sep 17 00:00:00 2001 From: wolves Date: Thu, 22 Jan 2026 23:51:20 +0800 Subject: [PATCH] routine --- 26/01/1895.cpp | 15 +++++++++++++++ 26/01/3507.cpp | 33 +++++++++++++++++++++++++++++++++ 26/01/comp/18q1.cpp | 23 +++++++++++++++++++++++ 26/01/go/3507.go | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 26/01/1895.cpp create mode 100644 26/01/3507.cpp create mode 100644 26/01/comp/18q1.cpp create mode 100644 26/01/go/3507.go diff --git a/26/01/1895.cpp b/26/01/1895.cpp new file mode 100644 index 0000000..8ca85e1 --- /dev/null +++ b/26/01/1895.cpp @@ -0,0 +1,15 @@ +#include + +class Solution { +public: + int largestMagicSquare(std::vector>& grid) { + int m = grid.size(); + int n = grid[0].size(); + std::vector> preM(m,std::vector(n,0)),preN(m,std::vector(n,0)); + for (int i = 0; i < m; i++) { + for(int j = 0;j < n;j++){ + preM[m][n] += grid[m][n]; + } + } + } +}; \ No newline at end of file diff --git a/26/01/3507.cpp b/26/01/3507.cpp new file mode 100644 index 0000000..096ed0c --- /dev/null +++ b/26/01/3507.cpp @@ -0,0 +1,33 @@ +#include +#include + +class Solution { +public: + bool isIncrease(std::vector& nums){ + for (int i = 1; i& nums) { + int ans = 0; + while (!isIncrease(nums)) { + int index = 0; + int minX = INT_MAX; + for (int i = 0; i< nums.size()-1; i++) { + int temp = nums[i]+nums[i+1]; + if (minX > temp) { + minX = temp; + index = i; + } + } + nums.erase(nums.begin()+index+1); + nums[index] = minX; + ans++; + } + return ans; + } +}; \ No newline at end of file diff --git a/26/01/comp/18q1.cpp b/26/01/comp/18q1.cpp new file mode 100644 index 0000000..edb2727 --- /dev/null +++ b/26/01/comp/18q1.cpp @@ -0,0 +1,23 @@ +#include + +class Solution { +public: + int vowelConsonantScore(std::string s) { + int v =0,c=0; + std::string col = "aeiou"; + for (auto i : s) { + if (i > 122 || i < 97) { + continue; + } + if (col.find(i) != std::string::npos) { + v++; + }else { + c++; + } + } + if (c==0) { + return 0; + } + return v/c; + } +}; \ No newline at end of file diff --git a/26/01/go/3507.go b/26/01/go/3507.go new file mode 100644 index 0000000..2fb000f --- /dev/null +++ b/26/01/go/3507.go @@ -0,0 +1,38 @@ +package A + +import "math" + +func isIncrease(nums []int) bool { + for i := range nums { + if i == len(nums)-1 { + break + } + if nums[i] > nums[i+1] { + return false + } + } + return true +} + +func minimumPairRemoval(nums []int) int { + ans := 0 + index := 0 + temp := 0 + for !isIncrease(nums) { + minX := math.MaxInt + for i := range nums { + if i == len(nums)-1 { + break + } + temp = nums[i] + nums[i+1] + if minX > temp { + minX = temp + index = i + } + } + nums[index] = minX + nums = append(nums[:index+1], nums[index+2:]...) + ans++ + } + return ans +}