Skip to content

Commit c7d9d2f

Browse files
authored
Improved task 1
1 parent 7e4a3ba commit c7d9d2f

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

.github/workflows/python.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Python CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python: ["pypy3.10", "3.9", "3.10", "3.11", "3.12", "3.13"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python }}
23+
- name: Install tox and any other packages
24+
run: pip install tox
25+
- name: Run tox
26+
# Run tox using the version of Python in `PATH`
27+
run: tox -e py

src/main/python/g0001_0100/s0001_two_sum/Solution.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# #Big_O_Time_O(n)_Space_O(n) #AI_can_be_used_to_solve_the_task
44
# #2024_06_06_Time_62_ms_(53.52%)_Space_17.8_MB_(37.79%)
55

6+
from typing import List
7+
68
class Solution:
79
def twoSum(self, numbers: List[int], target: int) -> List[int]:
810
index_map = {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import unittest
2+
import Solution
3+
4+
class TestSolution(unittest.TestCase):
5+
def setUp(self):
6+
self.sol = Solution()
7+
8+
def test_two_sum(self):
9+
self.assertEqual(self.sol.twoSum([2, 7, 11, 15], 9), [0, 1])
10+
11+
def test_two_sum2(self):
12+
self.assertEqual(self.sol.twoSum([3, 2, 4], 6), [1, 2])
13+
14+
def test_two_sum3(self):
15+
self.assertEqual(self.sol.twoSum([3, 3], 6), [0, 1])
16+
17+
def test_two_sum4(self):
18+
self.assertEqual(self.sol.twoSum([3, 3], 7), [-1, -1])

0 commit comments

Comments
 (0)