From 8b1ae512de9276e4e0017c70206bce1d7acee7e6 Mon Sep 17 00:00:00 2001 From: Di WANG Date: Tue, 24 Oct 2023 00:06:02 -0700 Subject: [PATCH 1/5] 198 house robber --- cpp/198-House-Robber.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cpp/198-House-Robber.cpp diff --git a/cpp/198-House-Robber.cpp b/cpp/198-House-Robber.cpp new file mode 100644 index 0000000..33ab49d --- /dev/null +++ b/cpp/198-House-Robber.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + int rob(vector& nums) { + int rob(vector& nums) { +if (nums.empty()) return 0; +int n = nums.size(); +if (n == 1) return nums[0]; +int pre2 = 0, pre1 = 0, cur; +for (int i = 0; i < n; ++i) { +cur = max(pre2 + nums[i], pre1); +pre2 = pre1; +pre1 = cur; +} +return cur; +} + } +}; \ No newline at end of file From 2dd580c30fb0fa57ca270ce60bdd4980450c3117 Mon Sep 17 00:00:00 2001 From: Di WANG Date: Tue, 24 Oct 2023 00:07:37 -0700 Subject: [PATCH 2/5] style check action --- .github/workflows/cppstylecheck.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cppstylecheck.yml b/.github/workflows/cppstylecheck.yml index bf49c26..f164ece 100644 --- a/.github/workflows/cppstylecheck.yml +++ b/.github/workflows/cppstylecheck.yml @@ -1,3 +1,11 @@ - - name: C++ Style Check - uses: coleaeason/actions-uncrustify@v1 - +on: [ pull_request ] + +jobs: + cpp_style_check: + runs-on: ubuntu-latest + name: Check C++ Style + steps: + - name: Checkout this commit + uses: actions/checkout@v2 + - name: Run style checks + uses: coleaeason/actions-uncrustify@v1 From 6784a02fbd3b736c1eadce9767199b4c9bb4e65d Mon Sep 17 00:00:00 2001 From: Di WANG Date: Tue, 24 Oct 2023 00:14:05 -0700 Subject: [PATCH 3/5] add gitconfig --- .gitconfig | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitconfig diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..b0b8a76 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,2 @@ +[safe] + directory = /.github/workspace From be8dec30974bcb72a8a4fd78dc23c89f5fa301cb Mon Sep 17 00:00:00 2001 From: Di WANG Date: Tue, 24 Oct 2023 00:16:00 -0700 Subject: [PATCH 4/5] add gitconfig --- .gitconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitconfig b/.gitconfig index b0b8a76..f695fff 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,2 +1,2 @@ [safe] - directory = /.github/workspace + directory = /github/workspace From ac64b75ec5f31628b61bc996977c75c7dc528129 Mon Sep 17 00:00:00 2001 From: Di WANG Date: Tue, 24 Oct 2023 00:24:29 -0700 Subject: [PATCH 5/5] rm gitconfig --- .gitconfig | 2 -- .github/workflows/cppstylecheck.yml | 11 ----------- 2 files changed, 13 deletions(-) delete mode 100644 .gitconfig delete mode 100644 .github/workflows/cppstylecheck.yml diff --git a/.gitconfig b/.gitconfig deleted file mode 100644 index f695fff..0000000 --- a/.gitconfig +++ /dev/null @@ -1,2 +0,0 @@ -[safe] - directory = /github/workspace diff --git a/.github/workflows/cppstylecheck.yml b/.github/workflows/cppstylecheck.yml deleted file mode 100644 index f164ece..0000000 --- a/.github/workflows/cppstylecheck.yml +++ /dev/null @@ -1,11 +0,0 @@ -on: [ pull_request ] - -jobs: - cpp_style_check: - runs-on: ubuntu-latest - name: Check C++ Style - steps: - - name: Checkout this commit - uses: actions/checkout@v2 - - name: Run style checks - uses: coleaeason/actions-uncrustify@v1