Compare commits

...

5 Commits

Author SHA1 Message Date
c36e503041 724 2024-07-09 00:00:51 +08:00
67baf83d27 Merge branch 'main' of http://git.wxchen.site/wxchen/lc 2024-07-08 23:35:20 +08:00
f5bc575378 home 2024-07-08 23:34:14 +08:00
Chenwenxuan
f151c946a2 add 2024-07-08 21:38:26 +08:00
Chenwenxuan
1951556e4b 测试版本 2024-07-08 21:38:10 +08:00
5 changed files with 30 additions and 13 deletions

5
.gitignore vendored
View File

@@ -1,2 +1,5 @@
.vscode .vscode
build build
/.vs
/.vscode
*.exe

View File

@@ -6,7 +6,8 @@
"${workspaceFolder}/**" "${workspaceFolder}/**"
], ],
"defines": [], "defines": [],
"intelliSenseMode": "linux-gcc-x64" "intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools"
} }
], ],
"version": 4 "version": 4

20
724.cpp Normal file
View File

@@ -0,0 +1,20 @@
class Solution {
public:
int pivotIndex(vector<int>& nums) {
if(nums.size() == 0) return -1;
vector<int> leftSum(nums.size(),0);
for(auto i = 0; i < nums.size(); i++){
leftSum[i] += nums[i];
}
for(auto i = 0; i < nums.size(); i++){
if(2 * leftSum[i] - nums[i] == leftSum[nums.size() - 1]){
return i;
}
}
return -1;
}
};

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.0) cmake_minimum_required(VERSION 3.6)
project(lc VERSION 0.1.0) project(lc VERSION 0.1.0)
include(CTest) include(CTest)

View File

@@ -1,10 +1,3 @@
/*
* @Description:
* @Version: 1.0
* @Autor: wxchen
* @Date: 2022-11-21 15:27:10
* @LastEditTime: 2022-11-21 21:08:42
*/
#include <iostream> #include <iostream>
#include <vector> #include <vector>
@@ -38,9 +31,9 @@ class Solution {
int main(int, char**) { int main(int, char**) {
// ListNode* head = new ListNode(1); ListNode* head = new ListNode(1);
// head -> next = new ListNode(3); head -> next = new ListNode(3);
// head -> next -> next = new ListNode(2); head -> next -> next = new ListNode(2);
Solution s; Solution s;
std::cout << s.reversePrint(head)[0] << s.reversePrint(head)[1] << s.reversePrint(head)[2] << std::endl; std::cout << s.reversePrint(head)[0] << s.reversePrint(head)[1] << s.reversePrint(head)[2] << std::endl;