wolves 2 mesiacov pred
rodič
commit
124c7332d8
4 zmenil súbory, kde vykonal 109 pridanie a 0 odobranie
  1. 15 0
      26/01/1895.cpp
  2. 33 0
      26/01/3507.cpp
  3. 23 0
      26/01/comp/18q1.cpp
  4. 38 0
      26/01/go/3507.go

+ 15 - 0
26/01/1895.cpp

@@ -0,0 +1,15 @@
+#include <vector>
+
+class Solution {
+public:
+    int largestMagicSquare(std::vector<std::vector<int>>& grid) {
+        int m = grid.size();
+        int n = grid[0].size();
+        std::vector<std::vector<int>> preM(m,std::vector<int>(n,0)),preN(m,std::vector<int>(n,0));
+        for (int i = 0; i < m; i++) {
+            for(int j = 0;j < n;j++){
+                preM[m][n] += grid[m][n];
+            }
+        }
+    }
+};

+ 33 - 0
26/01/3507.cpp

@@ -0,0 +1,33 @@
+#include <climits>
+#include <vector>
+
+class Solution {
+public:
+    bool isIncrease(std::vector<int>& nums){
+        for (int i = 1; i<nums.size(); ++i) {
+            if (nums[i] < nums[i-1]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    int minimumPairRemoval(std::vector<int>& 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;
+    }
+};

+ 23 - 0
26/01/comp/18q1.cpp

@@ -0,0 +1,23 @@
+#include <string>
+
+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;
+    }
+};

+ 38 - 0
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
+}

备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。