From 38d683d35692ca3d9702c8a70ede0bcb2cae4212 Mon Sep 17 00:00:00 2001 From: Sandarbh Singhal <123533242+Nothing-avil@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:02:51 +0530 Subject: [PATCH 1/7] feat: add solutions to lc problems: No.3021 --- .../README.md | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README.md b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README.md index f6b29d08966ba..690cc655fceda 100644 --- a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README.md +++ b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README.md @@ -59,19 +59,49 @@ ```python +class Solution: + def flowerGame(self, n: int, m: int) -> int: + count = (n + 1) // 2 + tol = (m + 1) // 2 + ecount = n // 2 + etol = m // 2 + return count * etol + ecount * tol ``` ```java - +class Solution { + public long flowerGame(int n, int m) { + long count = (n + 1) / 2; + long tol = (m + 1) / 2; + long ecount = n / 2; + long etol = m / 2; + return (count * etol + ecount * tol); + } +} ``` ```cpp - +class Solution { +public: + long long flowerGame(int n, int m) { + long long count = (n + 1) / 2; + long long tol = (m + 1) / 2; + long long ecount = n / 2; + long long etol = m / 2; + return (count * etol + ecount * tol); + } +}; ``` ```go - +func flowerGame(n int, m int) int64 { + count := int64((n + 1) / 2) + tol := int64((m + 1) / 2) + ecount := int64(n / 2) + etol := int64(m / 2) + return count*etol + ecount*tol +} ``` From 372e0884436cb06d7506ede2994175f748cfad10 Mon Sep 17 00:00:00 2001 From: Sandarbh Singhal <123533242+Nothing-avil@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:03:42 +0530 Subject: [PATCH 2/7] feat: add solutions to lc problems: No.3021 --- .../README_EN.md | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README_EN.md b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README_EN.md index cd4969c108bb9..96b63736ed80a 100644 --- a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README_EN.md +++ b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README_EN.md @@ -54,20 +54,51 @@ + ```python +class Solution: + def flowerGame(self, n: int, m: int) -> int: + count = (n + 1) // 2 + tol = (m + 1) // 2 + ecount = n // 2 + etol = m // 2 + return count * etol + ecount * tol ``` ```java - +class Solution { + public long flowerGame(int n, int m) { + long count = (n + 1) / 2; + long tol = (m + 1) / 2; + long ecount = n / 2; + long etol = m / 2; + return (count * etol + ecount * tol); + } +} ``` ```cpp - +class Solution { +public: + long long flowerGame(int n, int m) { + long long count = (n + 1) / 2; + long long tol = (m + 1) / 2; + long long ecount = n / 2; + long long etol = m / 2; + return (count * etol + ecount * tol); + } +}; ``` ```go - +func flowerGame(n int, m int) int64 { + count := int64((n + 1) / 2) + tol := int64((m + 1) / 2) + ecount := int64(n / 2) + etol := int64(m / 2) + return count*etol + ecount*tol +} ``` From e601b60ec6766b55ee9fd8a4ac422ca067f5232e Mon Sep 17 00:00:00 2001 From: Sandarbh Singhal <123533242+Nothing-avil@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:04:38 +0530 Subject: [PATCH 3/7] feat: add solutions to lc problems: No.3021 --- .../Solution.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.cpp diff --git a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.cpp b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.cpp new file mode 100644 index 0000000000000..76246d45b8c06 --- /dev/null +++ b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.cpp @@ -0,0 +1,10 @@ +class Solution { +public: + long long flowerGame(int n, int m) { + long long count = (n + 1) / 2; + long long tol = (m + 1) / 2; + long long ecount = n / 2; + long long etol = m / 2; + return (count * etol + ecount * tol); + } +}; From f1d8ebba69ae1b791cd6c8af49214779b8ee1e1b Mon Sep 17 00:00:00 2001 From: Sandarbh Singhal <123533242+Nothing-avil@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:05:15 +0530 Subject: [PATCH 4/7] feat: add solutions to lc problems: No.3021 --- .../3021.Alice and Bob Playing Flower Game/Solution.go | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.go diff --git a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.go b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.go new file mode 100644 index 0000000000000..1fc18a0531c92 --- /dev/null +++ b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.go @@ -0,0 +1,7 @@ +func flowerGame(n int, m int) int64 { + count := int64((n + 1) / 2) + tol := int64((m + 1) / 2) + ecount := int64(n / 2) + etol := int64(m / 2) + return count*etol + ecount*tol +} From 69b60d3c8fbc655c76ef9c6da4c5c7db3d55ea8e Mon Sep 17 00:00:00 2001 From: Sandarbh Singhal <123533242+Nothing-avil@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:05:56 +0530 Subject: [PATCH 5/7] feat: add solutions to lc problems: No.3021 --- .../3021.Alice and Bob Playing Flower Game/Solution.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.java diff --git a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.java b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.java new file mode 100644 index 0000000000000..d6f5266efbcb6 --- /dev/null +++ b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.java @@ -0,0 +1,9 @@ +class Solution { + public long flowerGame(int n, int m) { + long count = (n + 1) / 2; + long tol = (m + 1) / 2; + long ecount = n / 2; + long etol = m / 2; + return (count * etol + ecount * tol); + } +} From d1f7ae3a6ce7ea92574983bd9d93c19a0d6ddb97 Mon Sep 17 00:00:00 2001 From: Sandarbh Singhal <123533242+Nothing-avil@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:07:40 +0530 Subject: [PATCH 6/7] feat: add solutions to lc problems: No.3021 --- .../3021.Alice and Bob Playing Flower Game/Solution.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.py diff --git a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.py b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.py new file mode 100644 index 0000000000000..5e4f8b5cd372e --- /dev/null +++ b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/Solution.py @@ -0,0 +1,7 @@ +class Solution: + def flowerGame(self, n: int, m: int) -> int: + count = (n + 1) // 2 + tol = (m + 1) // 2 + ecount = n // 2 + etol = m // 2 + return count * etol + ecount * tol From 644dc255eaab6d2324243d92d9577660e04f6a26 Mon Sep 17 00:00:00 2001 From: Nothing-avil Date: Mon, 29 Jan 2024 06:43:13 +0000 Subject: [PATCH 7/7] style: format code and docs with prettier --- .../3021.Alice and Bob Playing Flower Game/README_EN.md | 1 - 1 file changed, 1 deletion(-) diff --git a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README_EN.md b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README_EN.md index 96b63736ed80a..66a95ad5c5659 100644 --- a/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README_EN.md +++ b/solution/3000-3099/3021.Alice and Bob Playing Flower Game/README_EN.md @@ -54,7 +54,6 @@ - ```python class Solution: def flowerGame(self, n: int, m: int) -> int: