Skip to content

Commit 7994547

Browse files
authored
Merge pull request #27 from Certseeds/dev
feature: update version 0.8.2
2 parents 1ebae62 + e120e45 commit 7994547

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2243
-38
lines changed

.github/workflows/pull_request.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ jobs:
3737
3838
- name: hardwares - cpu
3939
run: nproc; cat /proc/cpuinfo
40-
if: ${{matrix.os != 'windows-latest'}}
4140

4241
# ensure the path and files of project
4342
- name: ensure the path and files of project
@@ -49,12 +48,10 @@ jobs:
4948
sudo apt-get update && sudo apt-get install -y gcc-${GCC_V} g++-${GCC_V} ccache
5049
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 111
5150
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCC_V} 111
52-
if: ${{matrix.os != 'windows-latest'}}
5351
5452
- name: prepare libopencv
5553
run: |
5654
sudo apt-get update && sudo apt-get install libopencv-dev
57-
if: ${{matrix.os != 'windows-latest'}}
5855
5956
- name: Use cmake
6057
run: cmake --version
@@ -92,7 +89,6 @@ jobs:
9289

9390
- name: tree
9491
run: tree
95-
if: ${{matrix.os != 'windows-latest'}}
9692

9793
- name: cache configs output
9894
run: |
@@ -119,13 +115,11 @@ jobs:
119115
# ensure the path and files of project
120116
- name: ensure the path and files of project
121117
run: sudo apt-get install tree; tree
122-
if: ${{matrix.os != 'windows-latest'}}
123118

124119
- name: run script
125120
working-directory: ./script
126121
run: python3 file_template.py
127122

128123
- name: tree the packet
129124
run: tree
130-
if: ${{matrix.os != 'windows-latest'}}
131125

.idea/.gitignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/Project.xml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/file.template.settings.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16.6)
22

33
set(PROJECT_VERSION_MAJOR 0)
44
set(PROJECT_VERSION_MINOR 8)
5-
set(PROJECT_VERSION_PATCH 1)
5+
set(PROJECT_VERSION_PATCH 2)
66
project(CS203_DSAA_template
77
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
88
DESCRIPTION "Template for Algorithm Based on C++11 and Modern CMake"

algorithm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ enable_testing()
99
set(dependencies dp fft sort tree binary_search string_search graph moderncpp)
1010
LIST(APPEND dependencies 2021F stack array list effective_cpp)
1111
LIST(APPEND dependencies string trie math disjoint_set divide_merge)
12-
LIST(APPEND dependencies matrix cs302 queue)
12+
LIST(APPEND dependencies matrix cs302 queue associative_container)
1313
foreach (elementName IN LISTS dependencies)
1414
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${elementName})
1515
endforeach ()

algorithm/array/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ list(APPEND leetcode_order 674 697 so_03 1020 717)
1717
list(APPEND leetcode_order 724 240 so_21 so_45 so_61)
1818
list(APPEND leetcode_order 747 766 1606 48 59)
1919
list(APPEND leetcode_order 334 238 560 804 806)
20-
list(APPEND leetcode_order 807 811)
20+
list(APPEND leetcode_order 807 811 830 832 840)
21+
list(APPEND leetcode_order 849 852 867 868 896)
22+
list(APPEND leetcode_order 905 908 922)
2123
LIST(TRANSFORM leetcode_order PREPEND leetcode_)
2224

2325
set(dependencies ${dependencies} ${leetcode_order})

algorithm/array/leetcode_830.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
// SPDX-License-Identifier: MIT
3+
/*
4+
CS203_DSAA_template
5+
6+
Copyright (C) 2022 nanoseeds
7+
8+
*/
9+
#include "leetcode_830_test.hpp"
10+
11+
namespace leetcode_830 {
12+
13+
vector<vector<int32_t>> leetcode_830::largeGroupPositions(const string &S) {
14+
int end{1}, length{1};
15+
vector<vector<int32_t>> willreturn{};
16+
const auto s_size{static_cast<int32_t>(S.size())};
17+
for (int32_t i{1}; i < s_size; ++i) {
18+
end = i;
19+
if (S[i] == S[i - 1]) {
20+
length++;
21+
} else {
22+
if (length >= 3) {
23+
willreturn.push_back({end - length, end - 1});
24+
}
25+
length = 1;
26+
}
27+
}
28+
if (length >= 3) {
29+
willreturn.push_back({end - length + 1, end});
30+
}
31+
return willreturn;
32+
}
33+
34+
}

algorithm/array/leetcode_830_test.hpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
CS203_DSAA_template
4+
5+
Copyright (C) 2022 nanoseeds
6+
7+
*/
8+
//@Tag array
9+
//@Tag 数组
10+
#ifndef CS203_DSAA_TEMPLATE_ALGORITHM_ARRAY_LEETCODE_830_TEST_HPP
11+
#define CS203_DSAA_TEMPLATE_ALGORITHM_ARRAY_LEETCODE_830_TEST_HPP
12+
13+
#include <catch_main.hpp>
14+
#include <cstdint>
15+
#include <cstddef>
16+
#include <vector>
17+
#include <string>
18+
19+
namespace leetcode_830 {
20+
using std::vector;
21+
using std::string;
22+
23+
struct leetcode_830 {
24+
static vector<vector<int32_t>> largeGroupPositions(const string &s);
25+
};
26+
27+
using Catch::Matchers::Equals;
28+
29+
TEST_CASE("test case 1 [test_830]", "[test_830]") {
30+
static constexpr const char *const input{"abbxxxxzzy"};
31+
const vector<vector<int32_t>> output{{3, 6}};
32+
CHECK_THAT(output, Equals(leetcode_830::largeGroupPositions(input)));
33+
}
34+
35+
TEST_CASE("test case 2 [test_830]", "[test_830]") {
36+
static constexpr const char *const input{"abc"};
37+
const vector<vector<int32_t>> output{};
38+
CHECK_THAT(output, Equals(leetcode_830::largeGroupPositions(input)));
39+
}
40+
41+
TEST_CASE("test case 3 [test_830]", "[test_830]") {
42+
static constexpr const char *const input{"abcdddeeeeaabbbcd"};
43+
const vector<vector<int32_t>> output{{3, 5}, {6, 9}, {12, 14}};
44+
CHECK_THAT(output, Equals(leetcode_830::largeGroupPositions(input)));
45+
}
46+
TEST_CASE("test case 4 [test_830]", "[test_830]") {
47+
static constexpr const char *const input{"abz"};
48+
const vector<vector<int32_t>> output{};
49+
CHECK_THAT(output, Equals(leetcode_830::largeGroupPositions(input)));
50+
}
51+
}
52+
#endif //CS203_DSAA_TEMPLATE_ALGORITHM_ARRAY_LEETCODE_830_TEST_HPP

algorithm/array/leetcode_832.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
CS203_DSAA_template
4+
5+
Copyright (C) 2022 nanoseeds
6+
7+
*/
8+
#include "leetcode_832_test.hpp"
9+
10+
namespace leetcode_832 {
11+
12+
vector<vector<int>> leetcode_832::flipAndInvertImageConst(const vector<vector<int>> &image) {
13+
const auto m{image.size()};
14+
if (m == 0) {
15+
return image;
16+
}
17+
const auto n{image.front().size()};
18+
if (n == 0) {
19+
return image;
20+
}
21+
vector<vector<int32_t>> result(image);
22+
vector<uint8_t> traverse(n);
23+
for (size_t i{0}; i < m; ++i) {
24+
for (size_t left{0}, right{n - 1}; left < right && right < n; ++left, --right) {
25+
if (image[i][left] == image[i][right]) {
26+
result[i][left] = !image[i][left];
27+
result[i][right] = !image[i][right];
28+
}
29+
}
30+
if (n % 2 == 1) {
31+
result[i][n / 2] = !image[i][n / 2];
32+
}
33+
}
34+
return result;
35+
}
36+
37+
38+
}

0 commit comments

Comments
 (0)