From 88a101e0bddbc110950dffb751db19a76f747c8b Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 9 May 2026 04:48:55 -0600 Subject: [PATCH 1/2] adding updates --- .../top_150_questions_round_23/ex_11_h_index.py | 16 ++++++++++++++++ .../top_150_questions_round_23/ex_11_h_index.ts | 13 +++++++++++++ .../test_11_h_index_round_22.py | 17 +++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_23/ex_11_h_index.py create mode 100644 src/my_project/interviews_typescript/top_150_questions_round_23/ex_11_h_index.ts create mode 100644 tests/test_150_questions_round_23/test_11_h_index_round_22.py diff --git a/src/my_project/interviews/top_150_questions_round_23/ex_11_h_index.py b/src/my_project/interviews/top_150_questions_round_23/ex_11_h_index.py new file mode 100644 index 00000000..2bc31b7a --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_23/ex_11_h_index.py @@ -0,0 +1,16 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod + +class Solution: + def hIndex(self, citations: List[int]) -> int: + + citations.sort(reverse=True) + len_cit:int = len(citations) + answer:int = 0 + + for i in range(len_cit): + + if citations[i] >= i + 1: + answer = i + 1 + + return answer diff --git a/src/my_project/interviews_typescript/top_150_questions_round_23/ex_11_h_index.ts b/src/my_project/interviews_typescript/top_150_questions_round_23/ex_11_h_index.ts new file mode 100644 index 00000000..0d002863 --- /dev/null +++ b/src/my_project/interviews_typescript/top_150_questions_round_23/ex_11_h_index.ts @@ -0,0 +1,13 @@ +function hIndex(citations: number[]): number { + citations.sort((a, b) => b - a); + const lenCit: number = citations.length; + let answer: number = 0; + + for (let i = 0; i < lenCit; i++) { + if (citations[i] >= i + 1) { + answer = i + 1; + } + } + + return answer; +}; diff --git a/tests/test_150_questions_round_23/test_11_h_index_round_22.py b/tests/test_150_questions_round_23/test_11_h_index_round_22.py new file mode 100644 index 00000000..38fb4431 --- /dev/null +++ b/tests/test_150_questions_round_23/test_11_h_index_round_22.py @@ -0,0 +1,17 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_22\ +.ex_11_h_index import Solution + +class hIndexTestCase(unittest.TestCase): + + def test_h_index_test_1(self): + solution = Solution() + output = solution.hIndex(citations = [3,0,6,1,5]) + target = 3 + self.assertEqual(output, target) + + def test_h_index_test_2(self): + solution = Solution() + output = solution.hIndex(citations = [1,3,1]) + target = 1 + self.assertEqual(output, target) \ No newline at end of file From 0b1b24def0d028d9fb93de9b5a8bd49b611f2e93 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 9 May 2026 04:51:26 -0600 Subject: [PATCH 2/2] adding updates --- ...{test_11_h_index_round_22.py => test_11_h_index_round_23.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/test_150_questions_round_23/{test_11_h_index_round_22.py => test_11_h_index_round_23.py} (88%) diff --git a/tests/test_150_questions_round_23/test_11_h_index_round_22.py b/tests/test_150_questions_round_23/test_11_h_index_round_23.py similarity index 88% rename from tests/test_150_questions_round_23/test_11_h_index_round_22.py rename to tests/test_150_questions_round_23/test_11_h_index_round_23.py index 38fb4431..7550aeaf 100644 --- a/tests/test_150_questions_round_23/test_11_h_index_round_22.py +++ b/tests/test_150_questions_round_23/test_11_h_index_round_23.py @@ -1,5 +1,5 @@ import unittest -from src.my_project.interviews.top_150_questions_round_22\ +from src.my_project.interviews.top_150_questions_round_23\ .ex_11_h_index import Solution class hIndexTestCase(unittest.TestCase):