task_id
stringlengths
5
7
question
stringlengths
192
1.48k
test_list
listlengths
2
5
test_function
stringlengths
54
236
entry_point
stringclasses
1 value
test_matching
stringlengths
57
291
test_match_function
stringclasses
1 value
OOP/15
First, write a class named **FTGV** using the Python language. Then, within the **FTGV** class, write a public function called **find_target_value** that, given a sorted array and a target value, finds the target value in the array and returns its index. If the target value does not exist in the array, it returns the p...
[ "assert candidate([1,3,5,6], 5)==2", "assert candidate([1,3,5,6], 2)==1", "assert candidate([1,3,5,6], 7)==4" ]
def test_run(content1,content2): return FTGV().find_target_value(content1,content2)
test_run
assert candidate([["class FTGV", "def find_target_value"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/16
First, write a class **FSAEP** using the Python language, then write a public function **finding_positions** in the **LVPSS** class. Given an integer array **nums** sorted in non-decreasing order and a target value **target**, this function finds the starting and ending positions of the given target value in the array....
[ "assert candidate([5,7,7,8,8,10], 8)==[3,4]", "assert candidate([5,7,7,8,8,10], 6)==[-1,-1]", "assert candidate([], 0)==[-1,-1]" ]
def test_run(content1,content2): return LVPSS().long_valid_substring(content1,content2)
test_run
assert candidate([["class FSAEP", "def finding_positions"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/17
Firstly, write an **NCBT** class using the Python language. Then, within the **NCBT** class, write a public function named **numeric_combination**. Given a set of candidate numbers **candidates** and a target number **target**, this function should find all combinations in **candidates** that can sum up to the **target...
[ "assert candidate([10,1,2,7,6,1,5], 8)==[[1,1,6],[1,2,5],[1,7],[2,6]]", "assert candidate([2,5,2,1,2], 5)==[[1,2,2],[5]]" ]
def test_run(content1,content2): return NCBT().numeric_combination(content1,content2)
test_run
assert candidate([["class NCBT", "def numeric_combination"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/18
First, create a class called **TSPI** using the Python language. Then, within the **TSPI** class, write a public function called **smallest_positive_integer**. This function should take an unsorted array of integers called **nums** as input and find the smallest positive integer that is not present in the array.
[ "assert candidate([1,2,0])==3", "assert candidate([3,4,-1,1])==2", "assert candidate([7,8,9,11,12])==1" ]
def test_run(content1): return TSPI().smallest_positive_integer(content1)
test_run
assert candidate([["class TSPI", "def smallest_positive_integer"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/19
First, write an **HTRW** class using the Python language, then write a public function named **harvest_rainwater** within the **HTRW** class to solve the following problem. Problem: Given **n** non-negative integers representing the height of each pillar of width 1 in the diagram, calculate how much rainwater can be co...
[ "assert candidate([0,1,0,2,1,0,1,3,2,1,2,1])==6", "assert candidate([4,2,0,3,2,5])==9" ]
def test_run(content1): return HTRW().harvest_rainwater(content1)
test_run
assert candidate([["class HTRW", "def harvest_rainwater"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/20
First, write a class called **STFM** using the Python language. Then, within the **STFM** class, create a public function called **string_form**. This function should take two non-negative integers, **num1** and **num2**, represented as strings, and return their product as a string.
[ "assert candidate(\"123\", \"456\")==\"56088\"", "assert candidate(\"2\", \"3\")==\"6\"" ]
def test_run(content1,content2): return HTRW().harvest_rainwater(content1,content2)
test_run
assert candidate([["class STFM", "def string_form"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/21
First, write a **PMTTN** class using the Python language. Then, within the **PMTTN** class, create a public **permutation** function that takes an array **nums** without duplicate numbers as input and returns all possible permutations.
[ "assert candidate([1,2,3])==[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]", "assert candidate([0,1])==[[0,1],[1,0]]", "assert candidate([1])==[[1]]" ]
def test_run(content1): return PMTTN().permutation(content1)
test_run
assert candidate([["class PMTTN", "def permutation"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/22
First, write a **UQPTT** class using the Python language, then write a public **unique_permutations** function within the **UQPTT** class to solve the following problem. Problem: Given a sequence of **nums** containing duplicate numbers, return all unique permutations.
[ "assert candidate([1,1,2])==[[1,1,2],[1,2,1],[2,1,1]]", "assert candidate([1,2,3])==[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]" ]
def test_run(content1): return UQPTT().unique_permutations(content1)
test_run
assert candidate([["class UQPTT", "def unique_permutations"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/23
First, write a class called **RTICW** using the Python language. Then, within the **RTICW** class, create a public function called **rotate_image_clockwise**. This function should take a 2D matrix, represented by the variable matrix, with dimensions n × n, which represents an image. The function should rotate the image...
[ "assert candidate([[1,2,3],[4,5,6],[7,8,9]])==[[7,4,1],[8,5,2],[9,6,3]]", "assert candidate([[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]])==[[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]]" ]
def test_run(content1): return RTICW().rotate_image_clockwise(content1)
test_run
assert candidate([["class RTICW", "def rotate_image_clockwise"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/24
First, write a class called **AAGM** using the Python language. Then, within the **AAGM** class, create a public function called **anagram** that takes an array of strings as input. This function should group together anagrams and return the result as a list.
[ "assert candidate([\"eat\", \"tea\", \"tan\", \"ate\", \"nat\", \"bat\"])==[[\"bat\"],[\"nat\",\"tan\"],[\"ate\",\"eat\",\"tea\"]]", "assert candidate([\"\"])==[[\"\"]]", "assert candidate([\"a\"])==[[\"a\"]]" ]
def test_run(content1): return AAGM().anagram(content1)
test_run
assert candidate([["class AAGM", "def anagram"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/25
First, write a **PFTN** class using the Python language. Then, within the **PFTN** class, create a public **power_function** function that calculates the integer power of **x** to the n-th degree.
[ "assert candidate(2.00000, 10)==1024.00000", "assert candidate(2.10000, 3)==9.26100", "assert candidate(2.00000, -2)==0.25000" ]
def test_run(content1,content2): return PFTN().power_function(content1,content2)
test_run
assert candidate([["class PFTN", "def power_function"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/26
First, write a class called **FDSB** using the Python language. Then, within the **FDSB** class, write a public function called **find_subarray** that takes an integer array called **nums** as input. This function will find a contiguous subarray within **nums** that has the maximum sum.
[ "assert candidate([-2,1,-3,4,-1,2,1,-5,4])==6", "assert candidate([1])==1", "assert candidate([5,4,-1,7,8])==23" ]
def test_run(content1): return FDSB().find_subarray(content1)
test_run
assert candidate([["class FDSB", "def find_subarray"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/27
First, write a class called **CWSO** using the Python language. Then, within the **CWSO** class, create a public function called **clockwise_spiral_order**. This function takes a matrix with **m** rows and **n** columns as input and returns all the elements in the matrix in a clockwise spiral order.
[ "assert candidate([[1,2,3],[4,5,6],[7,8,9]])==[1,2,3,6,9,8,7,4,5]", "assert candidate([[1,2,3,4],[5,6,7,8],[9,10,11,12]])==[1,2,3,4,8,12,11,10,9,5,6,7]" ]
def test_run(content1): return CWSO().clockwise_spiral_order(content1)
test_run
assert candidate([["class CWSO", "def clockwise_spiral_order"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/28
First, write a class called **MMJL** using the Python language. Then, within the **MMJL** class, write a public function called **maximum_jump_length**. Given a non-negative integer array called **nums**, this function should determine whether it is possible to reach the last index based on the following rules: 1. Init...
[ "assert candidate([2,3,1,1,4])==True", "assert candidate([3,2,1,0,4])==False" ]
def test_run(content1): return MMJL().maximum_jump_length(content1)
test_run
assert candidate([["class MMJL", "def maximum_jump_length"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/29
Firstly, write a class named **MOLI** using Python language. Then, in the **MOLI** class, write a public function called **merge_overlapping_intervals** that takes an array **intervals** representing a collection of ranges, where each individual range is represented as intervals[i] = [start_i, end_i]. This function sho...
[ "assert candidate([[1,3],[2,6],[8,10],[15,18]])==[[1,6],[8,10],[15,18]]", "assert candidate([[1,4],[4,5]])==[[1,5]]" ]
def test_run(content1): return MOLI().merge_overlapping_intervals(content1)
test_run
assert candidate([["class MOLI", "def merge_overlapping_intervals"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/30
First, write a **STANOL** class using the Python language. Then, within the **STANOL** class, create a public function called **sorted_non_overlapping** that inserts a new interval into a sorted list of non-overlapping intervals, sorted by the starting points of each interval. This function should ensure that the inter...
[ "assert candidate([[1,3],[6,9]], [2,5])==[[1,5],[6,9]]", "assert candidate([[1,2],[3,5],[6,7],[8,10],[12,16]], [4,8])==[[1,2],[3,10],[12,16]]", "assert candidate([], [5,7])==[[5,7]]", "assert candidate([[1,5]], [2,3])==[[1,5]]", "assert candidate([[1,5]], [2,7])==[[1,7]]" ]
def test_run(content1,content2): return STANOL().sorted_non_overlapping(content1,content2)
test_run
assert candidate([["class STANOL", "def sorted_non_overlapping"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/31
First, write a **WDLH** class using the Python language, then write a public **word_length** function in the **WDLH** class to solve the following problem. Problem: Given a string **s**, the string **s** is composed of several words, separated by some space characters before and after the word, return the length of th...
[ "assert candidate(\"Hello World\")==5", "assert candidate(\" fly me to the moon \")==4", "assert candidate(\"luffy is still joyboy\")==6" ]
def test_run(content1): return WDLH().word_length(content1)
test_run
assert candidate([["class WDLH", "def word_length"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/32
First, write an **STP** class using the Python language. Then, in the **STP** class, write a public function named **shortest_path**. Given a m x n grid containing non-negative integers, this function should find a path from the top left corner to the bottom right corner that minimizes the sum of the numbers along the ...
[ "assert candidate([[1,3,1],[1,5,1],[4,2,1]])==7", "assert candidate([[1,2,3],[4,5,6]])==12" ]
def test_run(content1): return STP().shortest_path(content1)
test_run
assert candidate([["class STP", "def shortest_path"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/33
First, write a **NNTI** class using the Python language, then write a public **non_negative_integer** function in the **NNTI** class to solve the following problem. Problem: Given a non-empty array composed of integers representing a non-negative integer, add one to this number, and return the result with the highest d...
[ "assert candidate([1,2,3])==[1,2,4]", "assert candidate([4,3,2,1])==[4,3,2,2]", "assert candidate([0])==[1]" ]
def test_run(content1): return NNTI().non_negative_integer(content1)
test_run
assert candidate([["class NNTI", "def non_negative_integer"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/34
First, write a class called **BASTI** using the Python language. Then, within the **BASTI** class, create a public function called **binary_string**. This function should take two binary strings, **a** and **b**, as input and return their sum in the form of a binary string.
[ "assert candidate(\"11\", \"1\")==\"100\"", "assert candidate(\"1010\", \"1011\")==\"10101\"" ]
def test_run(content1,content2): return BASTI().binary_string(content1,content2)
test_run
assert candidate([["class BASTI", "def binary_string"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/35
First, write a **CRTP** class using the Python language. Then, within the **CRTP** class, implement a public function called **climb_rooftop** to solve the following problem: Suppose you are climbing a staircase and it takes **n** steps to reach the top. At each step, you can either climb 1 or 2 steps. How many distinc...
[ "assert candidate(2)==2", "assert candidate(3)==3" ]
def test_run(content1): return CRTP().climb_rooftop(content1)
test_run
assert candidate([["class CRTP", "def climb_rooftop"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/36
First, write a **TAFER** class using the Python language. Then, within the **TAFER** class, create a public **trans_fomer** function. This function takes two words, **word1** and **word2**, as input and returns the minimum number of operations required to transform **word1** into **word2**. There are three possible ope...
[ "assert candidate(\"horse\", \"ros\")==3", "assert candidate(\"intention\", \"execution\")==5" ]
def test_run(content1,content2): return TAFER().trans_fomer(content1,content2)
test_run
assert candidate([["class TAFER", "def trans_fomer"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/37
First, write a class called **STEZ** using the Python language. Then, within the **STEZ** class, create a public function called **element_setting_zero**. This function should take in an m x n matrix as input. If an element in the matrix is 0, it should set all the elements in its corresponding row and column to 0.
[ "assert candidate([[1,1,1],[1,0,1],[1,1,1]])==[[1,0,1],[0,0,0],[1,0,1]]", "assert candidate([[0,1,2,0],[3,4,5,2],[1,3,1,5]])==[[0,0,0,0],[0,4,5,0],[0,3,1,0]]" ]
def test_run(content1): return STEZ().element_setting_zero(content1)
test_run
assert candidate([["class STEZ", "def element_setting_zero"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/38
First, implement the **GYHT** class using the Python language. Then, write a public function called **YangHui_Triangle** within the **GYHT** class. This function should take a non-negative integer **numRows** as input and generate the first **numRows** rows of the Yang Hui triangle.
[ "assert candidate(5)==[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]", "assert candidate(1)==[[1]]" ]
def test_run(content1): return GYHT().Generate_Yang_Hui_Triangle(content1)
test_run
assert candidate([["class GYHT", "def YangHui_Triangle"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/39
First, implement the **FTMPA** class using the Python language. Then, write a public function called **Minimum_Path** in the **FTMPA** class. This function should aim to find the minimum path sum from top to bottom in a given **triangle**.
[ "assert candidate([[2],[3,4],[6,5,7],[4,1,8,3]])==11", "assert candidate([[-10]])==-10" ]
def test_run(content1): return FTMPA().Find_The_Minimum_Path_And(content1)
test_run
assert candidate([["class FTMPA", "def Minimum_Path"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/40
First, implement the **CMP** class using the Python language. Then, within the **CMP** class, write a public function called **Calculate_Maximum_Profit**. This function should take an array as input and calculate the maximum profit that can be obtained. Each element in the array represents the price of a given stock on...
[ "assert candidate([3,3,5,0,0,3,1,4])==6", "assert candidate([1,2,3,4,5])==4", "assert candidate([7,6,4,3,1])==0", "assert candidate([1])==0" ]
def test_run(content1): return CMP().Calculate_Maximum_Profit(content1)
test_run
assert candidate([["class CMP", "def Calculate_Maximum_Profit"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/41
First, implement the **FTLOTLS** class using the Python language. Then, write a public function called **Longest_Sequence** within the **FTLOTLS** class. This function should take an unsorted integer array called **nums** as input and find the length of the longest sequence of consecutive numbers (the sequence elements...
[ "assert candidate([100,4,200,1,3,2])==4", "assert candidate([0,3,7,2,5,8,4,6,0,1])==9" ]
def test_run(content1): return FTLOTLS().Find_The_Length_Of_The_Longest_Sequence(content1)
test_run
assert candidate([["class FTLOTLS", "def Longest_Sequence"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/42
First, implement the **AF** class using the Python language. Then, within the **AF** class, write a public function called **Area_Fill** that takes a given m x n matrix called **board**, which is composed of characters 'X' and 'O'. The function should find all the regions surrounded by 'X' and fill all the 'O' within t...
[ "assert candidate([[\"X\",\"X\",\"X\",\"X\"],[\"X\",\"O\",\"O\",\"X\"],[\"X\",\"X\",\"O\",\"X\"],[\"X\",\"O\",\"X\",\"X\"]])==[[\"X\",\"X\",\"X\",\"X\"],[\"X\",\"X\",\"X\",\"X\"],[\"X\",\"X\",\"X\",\"X\"],[\"X\",\"O\",\"X\",\"X\"]]", "assert candidate([[\"X\"]])==[[\"X\"]]" ]
def test_run(content1): return AF().Area_Fill(content1)
test_run
assert candidate([["class AF", "def Area_Fill"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/43
First, implement the **SS** class using the Python language. Then, within the **SS** class, write a public function called **Split_String** that takes a string **s** as input and returns all possible partition schemes of **s**, where each substring in the partition is a palindrome.
[ "assert candidate(\"aab\")==[[\"a\",\"a\",\"b\"],[\"aa\",\"b\"]]", "assert candidate(\"a\")==[[\"a\"]]" ]
def test_run(content1): return SS().Split_String(content1)
test_run
assert candidate([["class SS", "def Split_String"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/44
First, implement the **MNOD** class using the Python language. Then, within the **MNOD** class, write a public function called **Minimum_Divisions** that takes a string **s** as input. This function should split the string **s** into substrings, where each substring is a palindrome, and return the minimum number of div...
[ "assert candidate(\"aab\")==1", "assert candidate(\"a\")==0", "assert candidate(\"ab\")==1" ]
def test_run(content1): return MNOD().Minimum_Number_Of_Divisions(content1)
test_run
assert candidate([["class MNOD", "def Minimum_Divisions"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/45
Firstly, implement the **DSBCD** class using Python language. Then, write a public **distribute_candie** function in the **DSBCD** class to solve the following problem. Problem: **n** children are standing in a line, and an integer array **ratings** is given to represent the ratings of each child. Candies need to be di...
[ "assert candidate([1,0,2])==5", "assert candidate([1,2,2])==4" ]
def test_run(content1): return DSBCD().distribute_candie(content1)
test_run
assert candidate([["class DSBCD", "def distribute_candie"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/46
First, implement the **ITETAO** class using the Python language. Then, write a public function called **Appeared_Once** in the **ITETAO** class. This function should take a non-empty integer array called **nums** as input. The function should find the element that appears only once in the array, while all other element...
[ "assert candidate([2,2,1])==1", "assert candidate([4,1,2,1,2])==4", "assert candidate([1])==1" ]
def test_run(content1): return ITETAO().Identify_The_Element_That_Appeared_Once(content1)
test_run
assert candidate([["class ITETAO", "def Appeared_Once"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/47
Firstly, implement a **JS** class using Python language. Then, in the **JS** class, write a public function named **Judgment_Splicing**. This function should take a string **s** and a list of strings **wordDict** as a dictionary, and determine whether the string **s** can be spliced together using the words that appear...
[ "assert candidate(\"leetcode\", [\"leet\", \"code\"])==True", "assert candidate(\"applepenapple\", [\"apple\", \"pen\"])==True", "assert candidate(\"catsandog\", [\"cats\", \"dog\", \"sand\", \"and\", \"cat\"])==False" ]
def test_run(content1,content2): return JS().Judgment_Splicing(content1,content2)
test_run
assert candidate([["class JS", "def Judgment_Splicing"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/48
First, implement the **CS** class using the Python language. Then, write a public **Constructing_Sentences** function in the **CS** class to create a sentence by adding spaces in a given string **s**, using words from the wordDict string dictionary. The function should return all possible sentences that can be construc...
[ "assert candidate(\"catsanddog\", [\"cat\",\"cats\",\"and\",\"sand\",\"dog\"])==[\"cats and dog\",\"cat sand dog\"]", "assert candidate(\"pineapplepenapple\", [\"apple\",\"pen\",\"applepen\",\"pine\",\"pineapple\"])==[\"pine apple pen apple\",\"pineapple pen apple\",\"pine applepen apple\"]", "assert candidate(...
def test_run(content1,content2): return CS().Constructing_Sentences(content1,content2)
test_run
assert candidate([["class CS", "def Constructing_Sentences"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/49
Firstly, implement the **FTMP** class using Python language. Then, in the **FTMP** class, write a public function named **Most_Points**. This function should take an array of **points** as input, where points[i]=[x_i,y_i] represents a point on the X-Y plane. The function should return how many points can be on the same...
[ "assert candidate([[1,1],[2,2],[3,3]])==3", "assert candidate([[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]])==4" ]
def test_run(content1): return FTMP().Find_The_Most_Points(content1)
test_run
assert candidate([["class FTMP", "def Most_Points"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/50
First, implement the **CE** class using the Python language. Then, write a public function called **Calculating_Expressions** in the **CE** class to calculate the arithmetic expression represented by a given string array called **tokens**, which represents the expression in Reverse Polish Notation. The function should ...
[ "assert candidate([\"2\",\"1\",\"+\",\"3\",\"*\"])==9", "assert candidate([\"4\",\"13\",\"5\",\"/\",\"+\"])==6", "assert candidate([\"10\",\"6\",\"9\",\"3\",\"+\",\"-11\",\"*\",\"/\",\"*\",\"17\",\"+\",\"5\",\"+\"])==22" ]
def test_run(content1): return CE().Calculating_Expressions(content1)
test_run
assert candidate([["class CE", "def Calculating_Expressions"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/51
First, implement the **RWO** class using the Python language. Then, write a public function called **Reverse_Word_Order** in the **RWO** class to solve the following problem. Problem: Given a string **s**, return the order of the words in the reversed string.
[ "assert candidate(\"the sky is blue\")==\"blue is sky the\"", "assert candidate(\" hello world \")==\"world hello\"", "assert candidate(\"a good example\")==\"example good a\"" ]
def test_run(content1): return RWO().Reverse_Word_Order(content1)
test_run
assert candidate([["class RWO", "def Reverse_Word_Order"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/52
First, implement the **NCS** class using the Python language. Then, write a public **non_empty_subarray** function in the **NCS** class to solve the following problem: Problem: Given an integer array **nums**, find the contiguous subarray with the maximum product (the subarray must contain at least one number) and retu...
[ "assert candidate([2,3,-2,4])==6", "assert candidate([-2,0,-1])==0" ]
def test_run(content1): return NCS().non_empty_contiguous_subarray(content1)
test_run
assert candidate([["class NCS", "def non_empty_subarray"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/53
First, implement the **PE** class using the Python language. Then, write a public function called **Peak_elements** in the **PE** class to solve the following problem: Problem: Given an integer array **nums**, find a peak element and return its index. A peak element is defined as an element that is strictly greater tha...
[ "assert candidate([1,2,3,1])==2", "assert candidate([1,2,1,3,5,6,4])==1", "assert candidate([1,2,1,3,5,6,4])==5" ]
def test_run(content1): return PE().Peak_elementes(content1)
test_run
assert candidate([["class PE", "def Peak_elements"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/54
First, implement the **TMDBAE** class using the Python language. Then, write a public function called **adjacent_elements** in the **TMDBAE** class to solve the following problem: Problem: Given an unordered array **nums**, return the maximum difference between adjacent elements after sorting the array. If the number o...
[ "assert candidate([3,6,9,1])==3", "assert candidate([10])==0" ]
def test_run(content1): return TMDBAE().The_maximum_difference_between_adjacent_elements(content1)
test_run
assert candidate([["class TMDBAE", "def adjacent_elements"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/55
First, implement the **GME** class using the Python language. Then, write a public function called **get_most_elements** in the **GME** class to solve the following problem: Problem: Given an array **nums** of size **n**, return the majority element. The majority element is the element that appears more than ⌊n/2⌋ time...
[ "assert candidate([3,2,3])==3", "assert candidate([2,2,1,1,1,2,2])==2" ]
def test_run(content1): return GME().get_most_elements(content1)
test_run
assert candidate([["class GME", "def get_most_elements"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/56
First, implement the **GTNOTZ** class using the Python language. Then, write a public function called **get_trailing** within the **GTNOTZ** class to solve the following problem: Problem: Given an integer **n**, return the number of trailing zeros in the result of **n!**.
[ "assert candidate(3)==3", "assert candidate(5)==1" ]
def test_run(content1): return GTNOTZ().get_the_number_of_trailing_zeros(content1)
test_run
assert candidate([["class GTNOTZ", "def get_trailing"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/57
First, implement the **NNI** class using the Python language. Then, write a public function called **Non_negative_integers** in the **NNI** class to solve the following problem: Problem: Given a set of non-negative integers **nums**, rearrange the order of each number (without splitting any number) to form the largest ...
[ "assert candidate([10,2])==210", "assert candidate([3,30,34,5,9])==9534330" ]
def test_run(content1): return NNI().Non_negative_integers(content1)
test_run
assert candidate([["class NNI", "def Non_negative_integers"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/58
First, implement the **IRSID** class using the Python language. Then, write a public function named **sequences_DNA** in the **IRSID** class to solve the following problem: Problem: DNA sequences are composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. When studying DNA, it is useful to identify r...
[ "assert candidate([\"AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT\"])==[\"AAAAACCCCC\",\"CCCCCAAAAA\"]", "assert candidate(\"AAAAAAAAAAAAA\")==[\"AAAAAAAAAA\"]" ]
def test_run(content1): return IRSID().Identify_repetitive_sequences_in_DNA(content1)
test_run
assert candidate([["class IRSID", "def sequences_DNA"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/59
First, implement the **ERTTR** class using the Python language. Then, write a public function called **element_rotates** in the **ERTTR** class to solve the following problem: Problem: Given an integer array **nums**, rotate the elements in the array to the right by **k** positions and return the result.
[ "assert candidate([1,2,3,4,5,6,7],3)==[5,6,7,1,2,3,4]", "assert candidate([-1,-100,3,99],2)==[3,99,-1,-100]" ]
def test_run(content1,content2): return ERTTR().element_rotates_to_the_right(content1,content2)
test_run
assert candidate([["class ERTTR", "def element_rotates"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/60
First, implement the **ITBB** class using the Python language. Then, write a public function called **Invert_the_binary_bits** in the **ITBB** class to solve the following problem: Problem: Reverse the binary bits of a given 32-bit unsigned integer and return the unsigned integer result.
[ "assert candidate(00000010100101000001111010011100)==964176192", "assert candidate(11111111111111111111111111111101)==3221225471" ]
def test_run(content1): return ITBB().Invert_the_binary_bits(content1)
test_run
assert candidate([["class ITBB", "def Invert_the_binary_bits"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/61
First, implement the **RTN** class using the Python language. Then, write a public function called **Hamming_weight** in the **RTN** class to solve the following problem: Problem: Write a function that takes an unsigned integer as input (in the form of a binary string) and returns the number of '1' digits in its binary...
[ "assert candidate(00000000000000000000000000001011)==3", "assert candidate(00000000000000000000000010000000)==1", "assert candidate(11111111111111111111111111111101)==31" ]
def test_run(content1): return RTN().Returns_the_number(content1)
test_run
assert candidate([["class RTN", "def Hamming_weight"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/62
First, implement the **CTNOI** class using the Python language. Then, write a public function called **number_islands** in the **CTNOI** class to solve the following problem: Problem: Given a 2D grid consisting of '1' (land) and '0' (water), calculate the number of islands in the grid. An island is surrounded by water ...
[ "assert candidate([[\"1\",\"1\",\"1\",\"1\",\"0\"],[\"1\",\"1\",\"0\",\"1\",\"0\"],[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\",\"0\"]])==1", "assert candidate([[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"1\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"1\",\"1\"]])==3" ]
def test_run(content1): return CTNOI().Calculate_the_number_of_islands(content1)
test_run
assert candidate([["class CTNOI", "def number_islands"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/63
First, implement the **DABA** class using the Python language. Then, write a public function called **Digits_bitwise** in the **DABA** class to solve the following problem: Problem: Given two integers, **left** and **right**, representing the range [left, right], return the bitwise AND of all numbers in this range (inc...
[ "assert candidate(5,7)==4", "assert candidate(0,0)==0", "assert candidate(1,2147483647)==0" ]
def test_run(content1,content2): return DABA().Digits_are_bitwise_and(content1,content2)
test_run
assert candidate([["class DABA", "def Digits_bitwise"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/64
First, implement the **RV** class using the Python language. Then, write a public **Return_value** function in the **RV** class to solve the following problem: Problem: Given an integer **n**, return the count of prime numbers less than the non-negative integer **n**.
[ "assert candidate(10)==4", "assert candidate(0)==0", "assert candidate(1)==0" ]
def test_run(content1): return RV().Return_value(content1)
test_run
assert candidate([["class RV", "def Return_value"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/65
First, implement the **DIIII** class using Python language, then write a public function called **isomorphic** in the **DIIII** class to solve the following problem. Problem: Given two strings **s** and **t**, determine whether they are isomorphic. If the characters in **s** can be replaced by some mapping relationship...
[ "assert candidate(\"egg\",\"add\")==True", "assert candidate(\"foo\", \"bar\")==False", "assert candidate(\"paper\",\"title\")==True" ]
def test_run(content1,content2): return DIIII().Determine_if_it_is_isomorphic(content1,content2)
test_run
assert candidate([["class DIIII", "def isomorphic"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/66
First, implement the **FTA** class using the Python language. Then, write a public function called **Find_the_array** in the **FTA** class to solve the following problem: Problem: Given an array of **n** positive integers and a positive integer **target**, find the length of the smallest contiguous subarray [numsl, num...
[ "assert candidate(7, [2,3,1,2,4,3])==2", "assert candidate(4, [1,4,4])==1", "assert candidate(11, [1,1,1,1,1,1,1,1])==0" ]
def test_run(content1,content2): return FTA().Find_the_array(content1,content2)
test_run
assert candidate([["class FTA", "def Find_the_array"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/67
First, implement the **STPD** class using the Python language. Then, write a public function called **Shortest_Palindrome** in the **STPD** class to solve the following problem: Problem: Given a string **s**, convert it into a palindrome by adding characters at the beginning of the string. Find and return the shortest...
[ "assert candidate(\"aacecaaa\")==\"aaacecaaa\"", "assert candidate(\"abcd\")==\"dcbabcd\"" ]
def test_run(content1): return STPD().Shortest_Palindrome(content1)
test_run
assert candidate([["class STPD", "def Shortest_Palindrome"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/68
First, implement the **RTLE** class using the Python language. Then, write a public function **largest_element** in the **RTLE** class to solve the following problem: Problem: Given an integer array **nums** and an integer **k**, return the k-th largest element in the array.
[ "assert candidate([3,2,1,5,6,4],2)==5", "assert candidate([3,2,3,1,2,4,5,5,6],4)==4" ]
def test_run(content1,content2): return RTLE().Returns_the_largest_element(content1,content2)
test_run
assert candidate([["class RTLE", "def largest_element"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/69
First, implement the **GTAC** class using the Python language. Then, write a public function called **additive_combination** in the **GTAC** class to solve the following problem: Problem: Find all combinations of **k** numbers that add up to **n**, satisfying the following conditions: 1. Only use numbers from 1 to 9. ...
[ "assert candidate(3,7)==[[1,2,4]]", "assert candidate(3,9)==[[1,2,6], [1,3,5], [2,3,4]]", "assert candidate(4,1)==[]" ]
def test_run(content1,content2): return GTAC().Get_the_additive_combination(content1,content2)
test_run
assert candidate([["class GTAC", "def additive_combination"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/70
First, implement the **JTA** class using the Python language. Then, write a public function called **judging_the_array** in the **JTA** class to solve the following problem: Problem: Given an integer array **nums**, return True if any value appears at least twice in the array, and False if every element in the array is...
[ "assert candidate([1,2,3,1])==True", "assert candidate([1,2,3,4])==False", "assert candidate([1,1,1,3,3,4,3,2,4,2])==True" ]
def test_run(content1): return JTA().Judging_the_array(content1)
test_run
assert candidate([["class JTA", "def Judging_the_array"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/71
First, implement the **JI** class using the Python language. Then, write a public function called **Judgment_Index** in the **JI** class to solve the following problem: Problem: Given an integer array **nums** and an integer **k**, determine if there are two distinct indices **i** and **j** in the array such that nums[...
[ "assert candidate([1,2,3,1])==3", "assert candidate([1,0,1,1])==1", "assert candidate([1,2,3,1,2,3])==2" ]
def test_run(content1): return JI().Judgment_Index(content1)
test_run
assert candidate([["class JI", "def Judgment_Index"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/72
First, implement the **AC** class using the Python language. Then, write a public function called **Array_conditions** in the **AC** class to solve the following problem: Problem: Given an integer array **nums** and two integers **indexDiff** and **valueDiff**, find the index pair (i, j) that satisfies the following co...
[ "assert candidate([1,2,3,1],3,0)==True", "assert candidate([1,5,9,1,5,9],2,3)==False" ]
def test_run(content1,content2,content3): return AC().Array_conditions(content1,content2,content3)
test_run
assert candidate([["class AC", "def Array_conditions"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/73
First, implement the **FTLS** class using the Python language. Then, write a public function called **largest_square** in the **FTLS** class to solve the following problem: Problem: Given a 2D matrix consisting of '0' and '1', find the largest square that contains only '1' and return its area.
[ "assert candidate([[\"1\",\"0\",\"1\",\"0\",\"0\"],[\"1\",\"0\",\"1\",\"1\",\"1\"],[\"1\",\"1\",\"1\",\"1\",\"1\"],[\"1\",\"0\",\"0\",\"1\",\"0\"]])==4", "assert candidate([[\"0\",\"1\"],[\"1\",\"0\"]])==1", "assert candidate([[\"0\"]])==0" ]
def test_run(content1): return FTLS().Find_the_largest_square(content1)
test_run
assert candidate([["class FTLS", "def largest_square"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/74
First, implement the **CTMA** class using the Python language. Then, write a public function called **matrix_area** in the **CTMA** class to solve the following problem: Problem: Given two rectangles on a two-dimensional plane, each formed by lines parallel/vertical to the coordinate axes, calculate and return the tota...
[ "assert candidate(-3,0,3,4,0,-1,9,2)==45", "assert candidate(-2,-2,2,2,-2,-2,2,2)==16" ]
def test_run(content1,content2,content3,content4,content5,content6,content7,content8): return CTMA().Calculate_the_matrix_area(content1,content2,content3,content4,content5,content6,content7,content8)
test_run
assert candidate([["class CTMA", "def matrix_area"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/75
First, implement the **TAC** class using the Python language. Then, write a public function named **The_array_contains** in the **TAC** class to solve the following problem: Problem: Given a sorted integer array **nums** with no duplicate elements, return a list of the smallest sorted range intervals that exactly cover...
[ "assert candidate([0,1,2,4,5,7])==[\"0->2\",\"4->5\",\"7\"]", "assert candidate([0,2,3,4,6,8,9])==[\"0\",\"2->4\",\"6\",\"8->9\"]" ]
def test_run(content1): return TAC().The_array_contains(content1)
test_run
assert candidate([["class TAC", "def The_array_contains"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...
OOP/76
First, implement the **GTAC** class using the Python language. Then, write a public function called **array_count** in the **GTAC** class to solve the following problem: Problem: Given an integer array of size **n**, find all elements that appear more than ⌊n/3⌋ times.
[ "assert candidate([3,2,3])==[3]", "assert candidate([1])==[1]", "assert candidate([1,2])==[1,2]" ]
def test_run(content1): return GTAC().Get_the_array_count(content1)
test_run
assert candidate([["class GTAC", "def array_count"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]...