From 3ab71eebb1bf3bd2d61e8c0dd635cef40cfac15d Mon Sep 17 00:00:00 2001 From: rachyoung Date: Fri, 9 Feb 2024 19:38:01 -0500 Subject: [PATCH 1/3] 3028. Ant on the Boundary --- .idea/.gitignore | 8 ++++++++ .idea/OpenSourceContribution.iml | 12 ++++++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 7 +++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ Python/ant-on-the-boundary.py | 17 +++++++++++++++++ 7 files changed, 64 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/OpenSourceContribution.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Python/ant-on-the-boundary.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/OpenSourceContribution.iml b/.idea/OpenSourceContribution.iml new file mode 100644 index 00000000..b5ad51ab --- /dev/null +++ b/.idea/OpenSourceContribution.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..417e4258 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..cced0569 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Python/ant-on-the-boundary.py b/Python/ant-on-the-boundary.py new file mode 100644 index 00000000..b451a051 --- /dev/null +++ b/Python/ant-on-the-boundary.py @@ -0,0 +1,17 @@ +# Difficulty = Easy +# Submission Speed = 86.40% +''' +The ant returns to the boundary any time the running total of list elements equals zero. +We iterate through the list and increment the count any time the running total is zero. +''' + + +class Solution: + def returnToBoundaryCount(self, nums: List[int]) -> int: + count = 0 + sum = 0 + for i in range(len(nums)): + if sum == nums[i] * -1: + count += 1 + sum += nums[i] + return count \ No newline at end of file From e71f87f5f43628539cb9707997fd721d3bb2a6fe Mon Sep 17 00:00:00 2001 From: rachyoung Date: Sat, 10 Feb 2024 23:50:52 -0500 Subject: [PATCH 2/3] unchanged main branch --- Python/ant-on-the-boundary.py | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Python/ant-on-the-boundary.py diff --git a/Python/ant-on-the-boundary.py b/Python/ant-on-the-boundary.py deleted file mode 100644 index b451a051..00000000 --- a/Python/ant-on-the-boundary.py +++ /dev/null @@ -1,17 +0,0 @@ -# Difficulty = Easy -# Submission Speed = 86.40% -''' -The ant returns to the boundary any time the running total of list elements equals zero. -We iterate through the list and increment the count any time the running total is zero. -''' - - -class Solution: - def returnToBoundaryCount(self, nums: List[int]) -> int: - count = 0 - sum = 0 - for i in range(len(nums)): - if sum == nums[i] * -1: - count += 1 - sum += nums[i] - return count \ No newline at end of file From 1d046f3e4b7f191733e5f0842c5aa33661de9d02 Mon Sep 17 00:00:00 2001 From: rachyoung Date: Sat, 10 Feb 2024 23:54:14 -0500 Subject: [PATCH 3/3] 3028. Ant on the Boundary --- Python/ant-on-the-boundary.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Python/ant-on-the-boundary.py diff --git a/Python/ant-on-the-boundary.py b/Python/ant-on-the-boundary.py new file mode 100644 index 00000000..b451a051 --- /dev/null +++ b/Python/ant-on-the-boundary.py @@ -0,0 +1,17 @@ +# Difficulty = Easy +# Submission Speed = 86.40% +''' +The ant returns to the boundary any time the running total of list elements equals zero. +We iterate through the list and increment the count any time the running total is zero. +''' + + +class Solution: + def returnToBoundaryCount(self, nums: List[int]) -> int: + count = 0 + sum = 0 + for i in range(len(nums)): + if sum == nums[i] * -1: + count += 1 + sum += nums[i] + return count \ No newline at end of file