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