From 176d383dfa183418704c7bee0a52d54bcb4650aa Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 15 Jan 2026 04:13:14 -0600 Subject: [PATCH 1/2] addin algo --- .../ex_49_min_number_arrows_burst_ballons.py | 22 ++++++++++++++++++ ...in_number_arrows_burst_ballons_round_22.py | 23 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_22/ex_49_min_number_arrows_burst_ballons.py create mode 100644 tests/test_150_questions_round_22/test_49_min_number_arrows_burst_ballons_round_22.py diff --git a/src/my_project/interviews/top_150_questions_round_22/ex_49_min_number_arrows_burst_ballons.py b/src/my_project/interviews/top_150_questions_round_22/ex_49_min_number_arrows_burst_ballons.py new file mode 100644 index 00000000..61aece02 --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_22/ex_49_min_number_arrows_burst_ballons.py @@ -0,0 +1,22 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod + +class Solution: + def findMinArrowShots(self, points: List[List[int]]) -> int: + if not points: + return 0 + + # Sort balloons by end coordinate + points.sort(key=lambda x: x[1]) + + arrows = 1 + current_arrow_pos = points[0][1] + + for i in range(1, len(points)): + # If current balloon starts after the last arrow position, + # we need a new arrow + if points[i][0] > current_arrow_pos: + arrows += 1 + current_arrow_pos = points[i][1] + + return arrows \ No newline at end of file diff --git a/tests/test_150_questions_round_22/test_49_min_number_arrows_burst_ballons_round_22.py b/tests/test_150_questions_round_22/test_49_min_number_arrows_burst_ballons_round_22.py new file mode 100644 index 00000000..be34a785 --- /dev/null +++ b/tests/test_150_questions_round_22/test_49_min_number_arrows_burst_ballons_round_22.py @@ -0,0 +1,23 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_22\ +.ex_49_min_number_arrows_burst_ballons import Solution + +class ArrowsBurstBallonsTestCase(unittest.TestCase): + + def test_first_pattern(self): + solution = Solution() + output = solution.findMinArrowShots(points = [[10,16],[2,8],[1,6],[7,12]]) + target = 2 + self.assertEqual(output, target) + + def test_second_pattern(self): + solution = Solution() + output = solution.findMinArrowShots(points = [[1,2],[3,4],[5,6],[7,8]]) + target = 4 + self.assertEqual(output, target) + + def test_third_pattern(self): + solution = Solution() + output = solution.findMinArrowShots(points = [[1,2],[2,3],[3,4],[4,5]]) + target = 2 + self.assertEqual(output, target) \ No newline at end of file From e617c546da34e46ba8544242fb2fa9afdf0c3e2e Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 15 Jan 2026 04:19:53 -0600 Subject: [PATCH 2/2] adding algo typescript --- .../top_150_questions_round_1/ex_02_remove_element.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/my_project/interviews_typescript/top_150_questions_round_1/ex_02_remove_element.ts diff --git a/src/my_project/interviews_typescript/top_150_questions_round_1/ex_02_remove_element.ts b/src/my_project/interviews_typescript/top_150_questions_round_1/ex_02_remove_element.ts new file mode 100644 index 00000000..0b570ca9 --- /dev/null +++ b/src/my_project/interviews_typescript/top_150_questions_round_1/ex_02_remove_element.ts @@ -0,0 +1,11 @@ +function removeElement(nums: number[], val: number): number { + while (nums.includes(val)){ + const index = nums.indexOf(val); + nums.splice(index, 1); + } + + return nums.length; + +}; + +console.log(removeElement([3,2,2,3], 3)) \ No newline at end of file