Question:
def Strongest_Extension(class_name, extensions):
    """You will be given the name of a class (a string) and a list of extensions.
    The extensions are to be used to load additional classes to the class. The
    strength of the extension is as follows: Let CAP be the number of the uppercase
    letters in the extension's name, and let SM be the number of lowercase letters
    in the extension's name, the strength is given by the fraction CAP - SM.
    You should find the strongest extension and return a string in this
    format: ClassName.StrongestExtensionName.
    If there are two or more extensions with the same strength, you should
    choose the one that comes first in the list.
    For example, if you are given "Slices" as the class and a list of the
    extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
    return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
    (its strength is -1).
    Example:
    for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
    """


Question:
Write a function to determine if it is possible to get an array sorted in non-decreasing order by performing any number of right shift operations on the given array. If it is possible return True else return False. If the given array is empty then return True.
assert move_one_ball([3, 4, 5, 1, 2])==True
assert move_one_ball([3, 5, 10, 1, 2])==True
assert move_one_ball([4, 3, 1, 2])==False
assert move_one_ball([3, 5, 4, 1, 2])==False
assert move_one_ball([])==True


Question:
Write a function to reverse words in a given string.
assert reverse_words("python program")==("program python")
assert reverse_words("java language")==("language java")
assert reverse_words("indian man")==("man indian")


Question:
def count_key_changes(s: str) -> int:
    """
    You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = "ab" has a change of a key while s = "bBBb" does not have any.

    Return the number of times the user had to change the key.

    Note: Modifiers like shift or caps lock won't be counted in changing the key that is if a user typed the letter 'a' and then the letter 'A' then it will not be considered as a changing of key.

    Examples:
    >>> s = "aAbBcC"
    2
    >>> s = "AaAaAaaA"
    0

    Constraints:
    1 <= s.length <= 100
    s consists of only upper case and lower case English letters.
    """


Question:
Write a python function to check whether the given number is a perfect square or not.
assert is_Perfect_Square(10) == False
assert is_Perfect_Square(36) == True
assert is_Perfect_Square(14) == False


Question:
Write a function to add a dictionary to the tuple.
assert add_dict_to_tuple((4, 5, 6), {"MSAM" : 1, "is" : 2, "best" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})
assert add_dict_to_tuple((1, 2, 3), {"UTS" : 2, "is" : 3, "Worst" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})
assert add_dict_to_tuple((8, 9, 10), {"POS" : 3, "is" : 4, "Okay" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})


Question:
def sum_to_n(n: int):
    """sum_to_n is a function that sums numbers from 1 to n.
    >>> sum_to_n(30)
    465
    >>> sum_to_n(100)
    5050
    >>> sum_to_n(5)
    15
    >>> sum_to_n(10)
    55
    >>> sum_to_n(1)
    1
    """


Question:
Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.
assert super_seq("AGGTAB", "GXTXAYB", 6, 7) == 9
assert super_seq("feek", "eke", 4, 3) == 5
assert super_seq("PARRT", "RTA", 5, 3) == 6


Question:
def will_it_fly(q,w):
    '''
    Write a function that returns True if the object q will fly, and False otherwise.
    The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.

    Example:
    will_it_fly([1, 2], 5) ➞ False
    # 1+2 is less than the maximum possible weight, but it's unbalanced.

    will_it_fly([3, 2, 3], 1) ➞ False
    # it's balanced, but 3+2+3 is more than the maximum possible weight.

    will_it_fly([3, 2, 3], 9) ➞ True
    # 3+2+3 is less than the maximum possible weight, and it's balanced.

    will_it_fly([3], 5) ➞ True
    # 3 is less than the maximum possible weight, and it's balanced.
    '''


Question:
from typing import List

def generate_non_consecutive_zero_binary(n: int) -> List[str]:
    """
    You are given a positive integer n.

    A binary string x is valid if all substrings of x of length 2 contain at least one "1".

    Return all valid strings with length n, in any order.

    Examples:
    >>> n = 3
    ['010','011','101','110','111']
    >>> n = 1
    ['0','1']

    Constraints:
    1 <= n <= 18
    """


Question:
Write a function to filter the given list of any Python values, only keeping the integers.
assert filter_integers([]) == []
assert filter_integers([4, {}, [], 23.2, 9, 'adasd']) == [4, 9]
assert filter_integers([3, 'c', 3, 3, 'a', 'b']) == [3, 3, 3]


Question:
Write a function to assign frequency to each tuple in the given tuple list.
assert assign_freq([(6, 5, 8), (2, 7), (6, 5, 8), (6, 5, 8), (9, ), (2, 7)] ) == '[(6, 5, 8, 3), (2, 7, 2), (9, 1)]'
assert assign_freq([(4, 2, 4), (7, 1), (4, 8), (4, 2, 4), (9, 2), (7, 1)] ) == '[(4, 2, 4, 2), (7, 1, 2), (4, 8, 1), (9, 2, 1)]'
assert assign_freq([(11, 13, 10), (17, 21), (4, 2, 3), (17, 21), (9, 2), (4, 2, 3)] ) == '[(11, 13, 10, 1), (17, 21, 2), (4, 2, 3, 2), (9, 2, 1)]'


Question:
from typing import List

def has_close_elements(numbers: List[float], threshold: float) -> bool:
    """ Check if in given list of numbers, are any two numbers closer to each other than
    given threshold.
    >>> has_close_elements([1.0, 2.0, 3.0], 0.5)
    False
    >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
    True
    """


Question:
from typing import List
from collections import Counter
from heapq import heapify, heapreplace
from string import ascii_lowercase

def minimize_string_value(s: str) -> str:
    """
    You are given a string s. s[i] is either a lowercase English letter or '?'.

    For a string t having length m containing only lowercase English letters, we define the function cost(i) for an index i as the number of characters equal to t[i] that appeared before it, i.e. in the range [0, i - 1].

    The value of t is the sum of cost(i) for all indices i.

    For example, for the string t = "aab":

    cost(0) = 0
    cost(1) = 1
    cost(2) = 0
    Hence, the value of "aab" is 0 + 1 + 0 = 1.
    Your task is to replace all occurrences of '?' in s with any lowercase English letter so that the value of s is minimized.

    Return a string denoting the modified string with replaced occurrences of '?'. If there are multiple strings resulting in the minimum value, return the lexicographically smallest one.

    Examples:
    >>> s = "???"
    abc
    >>> s = "a?a?"
    abac

    Constraints:
    1 <= s.length <= 10^5
    s[i] is either a lowercase English letter or '?'.
    """


Question:
from typing import List
from collections import defaultdict
from math import isqrt
def number_of_quality_pairs(nums1: List[int], nums2: List[int], k: int) -> int:
    """
    You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k.

    A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1).

    Return the total number of good pairs.

    Examples:
    >>> nums1 = [1,3,4], nums2 = [1,3,4], k = 1
    5
    >>> nums1 = [1,2,4,12], nums2 = [2,4], k = 3
    2

    Constraints:
    1 <= n, m <= 50
    1 <= nums1[i], nums2[j] <= 50
    1 <= k <= 50
    """


Question:
Write a python function to find the missing number in a sorted array.
assert find_missing([1,2,3,5],4) == 4
assert find_missing([1,3,4,5],4) == 2
assert find_missing([1,2,3,5,6,7],5) == 4


Question:
def sort_even(l: list):
    """This function takes a list l and returns a list l' such that
    l' is identical to l in the odd indicies, while its values at the even indicies are equal
    to the values of the even indicies of l, but sorted.
    >>> sort_even([1, 2, 3])
    [1, 2, 3]
    >>> sort_even([5, 6, 3, 4])
    [3, 6, 5, 4]
    """


Question:
from typing import List
from math import inf

def minimum_moves(nums: List[int], k: int, maxChanges: int) -> int:
    """
    You are given a binary array nums of length n, a positive integer k and a non-negative integer maxChanges.

    Alice plays a game, where the goal is for Alice to pick up k ones from nums using the minimum number of moves. When the game starts, Alice picks up any index aliceIndex in the range [0, n - 1] and stands there. If nums[aliceIndex] == 1 , Alice picks up the one and nums[aliceIndex] becomes 0(this does not count as a move). After this, Alice can make any number of moves (including zero) where in each move Alice must perform exactly one of the following actions:

    Select any index j != aliceIndex such that nums[j] == 0 and set nums[j] = 1. This action can be performed at most maxChanges times.
    Select any two adjacent indices x and y (|x - y| == 1) such that nums[x] == 1, nums[y] == 0, then swap their values (set nums[y] = 1 and nums[x] = 0). If y == aliceIndex, Alice picks up the one after this move and nums[y] becomes 0.
    Return the minimum number of moves required by Alice to pick exactly k ones.

    Examples:
    >>> nums = [1,1,0,0,0,1,1,0,0,1], k = 3, maxChanges = 1
    3
    >>> nums = [0,0,0,0], k = 2, maxChanges = 3
    4

    Constraints:
    2 <= n <= 10^5
    0 <= nums[i] <= 1
    1 <= k <= 10^5
    0 <= maxChanges <= 10^5
    maxChanges + sum(nums) >= k
    """


Question:
from typing import List
from math import inf
from heapq import nlargest, nsmallest

def min_distance_after_removing_point(points: List[List[int]]) -> int:
    """
    You are given a array points representing integer coordinates of some points on a 2D plane, where points[i] = [x_i, y_i].

    The distance between two points is defined as their Manhattan distance.
    Return the minimum possible value for maximum distance between any two points by removing exactly one point.

    Examples:
    >>> points = [[3,10],[5,15],[10,2],[4,4]]
    12
    >>> points = [[1,1],[1,1],[1,1]]
    0

    Constraints:
    3 <= points.length <= 10^5
    points[i].length == 2
    1 <= points[i][0], points[i][1] <= 10^8
    """


Question:
def how_many_times(string: str, substring: str) -> int:
    """ Find how many times a given substring can be found in the original string. Count overlaping cases.
    >>> how_many_times('', 'a')
    0
    >>> how_many_times('aaa', 'a')
    3
    >>> how_many_times('aaaa', 'aa')
    3
    """


Question:
Write a function to return a sorted list of all elements from a given list of positive integers, where each element doesn't have any even digit.
assert unique_digits([15, 33, 1422, 1]) == [1, 15, 33]
assert unique_digits([152, 323, 1422, 10]) == []
assert unique_digits([12345, 2033, 111, 151]) == [111, 151]
assert unique_digits([135, 103, 31]) == [31, 135]


Question:
Write a function to calculate the perimeter of a regular polygon.
assert perimeter_polygon(4,20)==80
assert perimeter_polygon(10,15)==150
assert perimeter_polygon(9,7)==63


Question:
Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.
assert max_product([3, 100, 4, 5, 150, 6], 6) == 45000
assert max_product([4, 42, 55, 68, 80], 5) == 50265600
assert max_product([10, 22, 9, 33, 21, 50, 41, 60], 8) == 21780000


Question:
Write a function to search some literals strings in a string by using regex.
assert check_literals('The quick brown fox jumps over the lazy dog.',['fox']) == 'Matched!'
assert check_literals('The quick brown fox jumps over the lazy dog.',['horse']) == 'Not Matched!'
assert check_literals('The quick brown fox jumps over the lazy dog.',['lazy']) == 'Matched!'


Question:
Write a function to sort the given array by using heap sort.
assert heap_sort([12, 2, 4, 5, 2, 3]) == [2, 2, 3, 4, 5, 12]
assert heap_sort([32, 14, 5, 6, 7, 19]) == [5, 6, 7, 14, 19, 32]
assert heap_sort([21, 15, 29, 78, 65]) == [15, 21, 29, 65, 78]


Question:
def any_int(x, y, z):
    '''
    Create a function that takes 3 numbers.
    Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
    Returns false in any other cases.

    Examples
    any_int(5, 2, 7) ➞ True

    any_int(3, 2, 2) ➞ False

    any_int(3, -2, 1) ➞ True

    any_int(3.6, -2.2, 2) ➞ False

    '''


Question:
def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """


Question:
Write a function to find the maximum sum we can make by dividing number in three parts recursively and summing them up together for the given number.
assert breakSum(12) == 13
assert breakSum(24) == 27
assert breakSum(23) == 23


Question:
from typing import List

def count_alternating_subarrays(nums: List[int]) -> int:
    """
    You are given a binary array nums.

    We call a subarray alternating if no two adjacent elements in the subarray have the same value.

    Return the number of alternating subarrays in nums.

    Examples:
    >>> nums = [0,1,1,1]
    5
    >>> nums = [1,0,1,0]
    10

    Constraints:
    1 <= nums.length <= 10^5
    nums[i] is either 0 or 1.
    """


Question:
Write a function to get the n largest items from a dataset.
assert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2)==[100,90]
assert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5)==[100,90,80,70,60]
assert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3)==[100,90,80]


Question:
Write a function to obtain the Roman numeral equivalent of a given positive integer, and return it in lowercase. The integer restricts from 1 to 1000.
assert int_to_mini_roman(19) == 'xix'
assert int_to_mini_roman(152) == 'clii'
assert int_to_mini_roman(251) == 'ccli'
assert int_to_mini_roman(426) == 'cdxxvi'
assert int_to_mini_roman(500) == 'd'
assert int_to_mini_roman(1) == 'i'
assert int_to_mini_roman(4) == 'iv'
assert int_to_mini_roman(43) == 'xliii'
assert int_to_mini_roman(90) == 'xc'
assert int_to_mini_roman(94) == 'xciv'
assert int_to_mini_roman(532) == 'dxxxii'
assert int_to_mini_roman(900) == 'cm'
assert int_to_mini_roman(994) == 'cmxciv'
assert int_to_mini_roman(1000) == 'm'


Question:
from typing import List

def get_child_with_ball_after_k_seconds(n: int, k: int) -> int:
    """
    You are given two positive integers n and k. There are n children numbered from 0 to n - 1 standing in a queue in order from left to right.

    Initially, child 0 holds a ball and the direction of passing the ball is towards the right direction. After each second, the child holding the ball passes it to the child next to them. Once the ball reaches either end of the line, i.e. child 0 or child n - 1, the direction of passing is reversed.

    Return the number of the child who receives the ball after k seconds.

    Examples:
    >>> n = 3, k = 5
    1
    >>> n = 5, k = 6
    2

    Constraints:
    2 <= n <= 50
    1 <= k <= 50
    """


Question:
def sum_squares(lst):
    """"
    This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a
    multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not
    change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries.

    Examples:
    For lst = [1,2,3] the output should be 6
    For lst = []  the output should be 0
    For lst = [-1,-5,2,-1,-5]  the output should be -126
    """


Question:
Write a function to remove lowercase substrings from a given string.
assert remove_lowercase("PYTHon")==('PYTH')
assert remove_lowercase("FInD")==('FID')
assert remove_lowercase("STRinG")==('STRG')


Question:
from typing import List
from itertools import pairwise

def is_array_special(nums: List[int]) -> bool:
    """
    An array is considered special if every pair of its adjacent elements contains two numbers with different parity.

    You are given an array of integers nums. Return true if nums is a special array, otherwise, return false.

    Examples:
    >>> nums = [1]
    true
    >>> nums = [2,1,4]
    true

    Constraints:
    1 <= nums.length <= 100
    1 <= nums[i] <= 100
    """


Question:
from typing import List, Tuple

def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """


Question:
def is_nested(string):
    '''
    Create a function that takes a string as input which contains only square brackets.
    The function should return True if and only if there is a valid subsequence of brackets
    where at least one bracket in the subsequence is nested.

    is_nested('[[]]') ➞ True
    is_nested('[]]]]]]][[[[[]') ➞ False
    is_nested('[][]') ➞ False
    is_nested('[]') ➞ False
    is_nested('[[][]]') ➞ True
    is_nested('[[]][[') ➞ True
    '''


Question:
Write a function to sort the tuples alphabetically by the first item of each tuple.
assert sort_tuple([("Amana", 28), ("Zenat", 30), ("Abhishek", 29),("Nikhil", 21), ("B", "C")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]
assert sort_tuple([("aaaa", 28), ("aa", 30), ("bab", 29), ("bb", 21), ("csa", "C")]) == [('aa', 30), ('aaaa', 28), ('bab', 29), ('bb', 21), ('csa', 'C')]
assert sort_tuple([("Sarala", 28), ("Ayesha", 30), ("Suman", 29),("Sai", 21), ("G", "H")]) == [('Ayesha', 30), ('G', 'H'), ('Sai', 21), ('Sarala', 28), ('Suman', 29)]


Question:
from typing import List

def max_points_inside_square(points: List[List[int]], s: str) -> int:
    """
    You are given a 2D array points and a string s where, points[i] represents the coordinates of point i, and s[i] represents the tag of point i.

    A valid square is a square centered at the origin (0, 0), has edges parallel to the axes, and does not contain two points with the same tag.

    Return the maximum number of points contained in a valid square.

    Note:

    A point is considered to be inside the square if it lies on or within the square's boundaries.
    The side length of the square can be zero.

    Examples:
    >>> points = [[2,2],[-1,-2],[-4,4],[-3,1],[3,-3]], s = "abdca"
    2
    >>> points = [[1,1],[-2,-2],[-2,2]], s = "abb"
    1
    >>> points = [[1,1],[-1,-1],[2,-2]], s = "ccd"
    0

    Constraints:
    1 <= s.length, points.length <= 10^5
    points[i].length == 2
    -10^9 <= points[i][0], points[i][1] <= 10^9
    s.length == points.length
    points consists of distinct coordinates.
    s consists only of lowercase English letters.
    """


Question:
def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between
    two consonants from the right side of the word (case sensitive).

    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition.

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """


Question:
from typing import List

def min_levels_to_get_more_points(possible: List[int]) -> int:
    """
    You are given a binary array possible of length n.

    Alice and Bob are playing a game that consists of n levels. Some of the levels in the game are impossible to clear while others can always be cleared. In particular, if possible[i] == 0, then the ith level is impossible to clear for both the players. A player gains 1 point on clearing a level and loses 1 point if the player fails to clear it.

    At the start of the game, Alice will play some levels in the given order starting from the 0th level, after which Bob will play for the rest of the levels.

    Alice wants to know the minimum number of levels she should play to gain more points than Bob, if both players play optimally to maximize their points.

    Return the minimum number of levels Alice should play to gain more points. If this is not possible, return -1.

    Note that each player must play at least 1 level.

    Examples:
    >>> possible = [1,0,1,0]
    1
    >>> possible = [1,1,1,1,1]
    3
    >>> possible = [0,0]
    -1

    Constraints:
    2 <= n == possible.length <= 10^5
    possible[i] is either 0 or 1.
    """


Question:
def min_chairs_in_waiting_room(s: str) -> int:
    """
    You are given a string s. Simulate events at each second i:

    If s[i] == 'E', a person enters the waiting room and takes one of the chairs in it.
    If s[i] == 'L', a person leaves the waiting room, freeing up a chair.
    Return the minimum number of chairs needed so that a chair is available for every person who enters the waiting room given that it is initially empty.

    Examples:
    >>> s = "EEEEEEE"
    7
    >>> s = "ELELEEL"
    2

    Constraints:
    1 <= s.length <= 50
    s consists only of the letters 'E' and 'L'.
    s represents a valid sequence of entries and exits.
    """


Question:
Write a function to remove particular data type elements from the given tuple.
assert remove_datatype((4, 5, 4, 7.7, 1.2), int) == [7.7, 1.2]
assert remove_datatype((7, 8, 9, "SR"), str) == [7, 8, 9]
assert remove_datatype((7, 1.1, 2, 2.2), float) == [7, 2]


Question:
def encode_cyclic(s: str):
    """
    returns encoded string by cycling groups of three characters.
    """
    # split string to groups. Each of length 3.
    groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
    # cycle elements in each group. Unless group has fewer elements than 3.
    groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
    return "".join(groups)

def decode_cyclic(s: str):
    """
    takes as input string encoded with encode_cyclic function. Returns decoded string.
    """


Question:
Write a function to find nth centered hexagonal number.
assert centered_hexagonal_number(10) == 271
assert centered_hexagonal_number(2) == 7
assert centered_hexagonal_number(9) == 217


Question:
Write a function to find the sum of geometric progression series.
assert sum_gp(1,5,2)==31
assert sum_gp(1,5,4)==341
assert sum_gp(2,6,3)==728


Question:
Write a python function to find whether the given number is present in the infinite sequence or not.
assert does_Contain_B(1,7,3) == True
assert does_Contain_B(1,-3,5) == False
assert does_Contain_B(3,2,5) == False


Question:
Write a function to find the area of a rombus.
assert rombus_area(10,20)==100
assert rombus_area(10,5)==25
assert rombus_area(4,2)==4


Question:
Write a function to extract year, month and date from a url by using regex.
assert extract_date("https://www.washingtonpost.com/news/football-insider/wp/2016/09/02/odell-beckhams-fame-rests-on-one-stupid-little-ball-josh-norman-tells-author/") == [('2016', '09', '02')]
assert extract_date("https://www.indiatoday.in/movies/celebrities/story/wp/2020/11/03/odeof-sushant-singh-rajput-s-death-his-brother-in-law-shares-advice-for-fans-1749646/") == [('2020', '11', '03')]
assert extract_date("https://economictimes.indiatimes.com/news/economy/2020/12/29/finance/pension-assets-under-pfrda-touch-rs-5-32-lakh-crore/articleshow/79736619.cms") == [('2020', '12', '29')]


Question:
from typing import List

def triangle_type(nums: List[int]) -> str:
    """
    You are given a 0-indexed integer array nums of size 3 which can form the sides of a triangle.

    A triangle is called equilateral if it has all sides of equal length.
    A triangle is called isosceles if it has exactly two sides of equal length.
    A triangle is called scalene if all its sides are of different lengths.
    Return a string representing the type of triangle that can be formed or "none" if it cannot form a triangle.

    Examples:
    >>> nums = [3,3,3]
    "equilateral"
    >>> nums = [3,4,5]
    "scalene"

    Constraints:
    nums.length == 3
    1 <= nums[i] <= 100
    """


Question:
def add_elements(arr, k):
    """
    Given a non-empty array of integers arr and an integer k, return
    the sum of the elements with at most two digits from the first k elements of arr.

    Example:

        Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
        Output: 24 # sum of 21 + 3

    Constraints:
        1. 1 <= len(arr) <= 100
        2. 1 <= k <= len(arr)
    """


Question:
Write a python function to count true booleans in the given list.
assert count([True,False,True]) == 2
assert count([False,False]) == 0
assert count([True,True,True]) == 3


Question:
from typing import List

def sum_of_power(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums of length n and a positive integer k.

    The power of an array of integers is defined as the number of subsequences with their sum equal to k.

    Return the sum of power of all subsequences of nums.

    Since the answer may be very large, return it modulo 10^9 + 7.

    Examples:
    >>> nums = [1,2,3], k = 3
    6
    >>> nums = [2,3,3], k = 5
    4
    >>> nums = [1,2,3], k = 7
    0

    Constraints:
    1 <= n <= 100
    1 <= nums[i] <= 10^4
    1 <= k <= 100
    """


Question:
Write a python function to set the right most unset bit.
assert set_Right_most_Unset_Bit(21) == 23
assert set_Right_most_Unset_Bit(11) == 15
assert set_Right_most_Unset_Bit(15) == 15


Question:
def derivative(xs: list):
    """ xs represent coefficients of a polynomial.
    xs[0] + xs[1] * x + xs[2] * x^2 + ....
     Return derivative of this polynomial in the same form.
    >>> derivative([3, 1, 2, 4, 5])
    [1, 4, 12, 20]
    >>> derivative([1, 2, 3])
    [2, 6]
    """


Question:
def strlen(string: str) -> int:
    """ Return length of given string
    >>> strlen('')
    0
    >>> strlen('abc')
    3
    """


Question:
Write a python function to find the sum of all even natural numbers within the range l and r.
assert sum_Even(2,5) == 6
assert sum_Even(3,8) == 18
assert sum_Even(4,6) == 10


Question:
Write a python function to find the minimum of two numbers.
assert minimum(1,2) == 1
assert minimum(-5,-4) == -5
assert minimum(0,0) == 0


Question:
def same_chars(s0: str, s1: str):
    """
    Check if two words have the same characters.
    >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
    True
    >>> same_chars('abcd', 'dddddddabc')
    True
    >>> same_chars('dddddddabc', 'abcd')
    True
    >>> same_chars('eabcd', 'dddddddabc')
    False
    >>> same_chars('abcd', 'dddddddabce')
    False
    >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
    False
    """


Question:
from typing import List
import heapq
def edges_in_shortest_paths(n: int, edges: List[List[int]]) -> List[bool]:
    """
    You are given an undirected weighted graph of n nodes numbered from 0 to n - 1. The graph consists of m edges represented by a 2D array edges, where edges[i] = [a_i, b_i, w_i] indicates that there is an edge between nodes a_i and b_i with weight w_i.

    Consider all the shortest paths from node 0 to node n - 1 in the graph. You need to find a boolean array answer where answer[i] is true if the edge edges[i] is part of at least one shortest path. Otherwise, answer[i] is false.

    Return the array answer.

    Note that the graph may not be connected.

    Examples:
    >>> n = 6, edges = [[0,1,4],[0,2,1],[1,3,2],[1,4,3],[1,5,1],[2,3,1],[3,5,3],[4,5,2]]
    [true,true,true,false,true,true,true,false]
    >>> n = 4, edges = [[2,0,1],[0,1,1],[0,3,4],[3,2,2]]
    [true,false,false,true]

    Constraints:
    2 <= n <= 5 * 10^4
    m == edges.length
    1 <= m <= min(5 * 10^4, n * (n - 1) / 2)
    0 <= a_i, b_i < n
    a_i != b_i
    1 <= w_i <= 10^5
    There are no repeated edges.
    """


Question:
Write a python function to count negative numbers in a list.
assert neg_count([-1,-2,3,-4,-5]) == 4
assert neg_count([1,2,3]) == 0
assert neg_count([1,2,-3,-10,20]) == 2


Question:
Write a function to find the longest chain which can be formed from the given set of pairs.
assert max_chain_length([Pair(5, 24), Pair(15, 25),Pair(27, 40), Pair(50, 60)], 4) == 3
assert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4
assert max_chain_length([Pair(19, 10), Pair(11, 12),Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5


Question:
Write a function to add consecutive numbers of a given list.
assert add_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[2, 4, 7, 8, 9, 11, 13]
assert add_consecutive_nums([4, 5, 8, 9, 6, 10])==[9, 13, 17, 15, 16]
assert add_consecutive_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[3, 5, 7, 9, 11, 13, 15, 17, 19]


Question:
Write a function to find the number of subsequences having product smaller than k for the given non negative array.
assert no_of_subsequences([1,2,3,4], 10) == 11
assert no_of_subsequences([4,8,7,2], 50) == 9
assert no_of_subsequences([5,6,7,8], 15) == 4


Question:
Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.
assert generate_matrix(3)==[[1, 2, 3], [8, 9, 4], [7, 6, 5]]
assert generate_matrix(2)==[[1,2],[4,3]]
assert generate_matrix(7)==[[1, 2, 3, 4, 5, 6, 7], [24, 25, 26, 27, 28, 29, 8], [23, 40, 41, 42, 43, 30, 9], [22, 39, 48, 49, 44, 31, 10], [21, 38, 47, 46, 45, 32, 11], [20, 37, 36, 35, 34, 33, 12], [19, 18, 17, 16, 15, 14, 13]]


Question:
Write a function to find numbers within a given range where every number is divisible by every digit it contains.
assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]
assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]
assert divisible_by_digits(20,25)==[22, 24]


Question:
Write a function to sort a list of elements using radix sort.
assert radix_sort([15, 79, 25, 68, 37]) == [15, 25, 37, 68, 79]
assert radix_sort([9, 11, 8, 7, 3, 2]) == [2, 3, 7, 8, 9, 11]
assert radix_sort([36, 12, 24, 26, 29]) == [12, 24, 26, 29, 36]


Question:
Write a python function to find the largest number that can be formed with the given digits.
assert find_Max_Num([1,2,3],3) == 321
assert find_Max_Num([4,5,6,1],4) == 6541
assert find_Max_Num([1,2,3,9],4) == 9321


Question:
import math

def poly(xs: list, x: float):
    """
    Evaluates polynomial with coefficients xs at point x.
    return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
    """
    return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])

def find_zero(xs: list):
    """ xs are coefficients of a polynomial.
    find_zero find x such that poly(x) = 0.
    find_zero returns only only zero point, even if there are many.
    Moreover, find_zero only takes list xs having even number of coefficients
    and largest non zero coefficient as it guarantees
    a solution.
    >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
    -0.5
    >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
    1.0
    """


Question:
from typing import List

def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
    """ Filter an input list of strings only for ones that start with a given prefix.
    >>> filter_by_prefix([], 'a')
    []
    >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
    ['abc', 'array']
    """


Question:
def balanced_substrings(s: str) -> int:
    """
    Given a string s, you need to partition it into one or more balanced substrings. For example, if s == "ababcc" then ("abab", "c", "c"), ("ab", "abc", "c"), and ("ababcc") are all valid partitions, but ("a", "bab", "cc"), ("aba", "bc", "c"), and ("ab", "abcc") are not. The unbalanced substrings are bolded.

    Return the minimum number of substrings that you can partition s into.

    Note: A balanced string is a string where each character in the string occurs the same number of times.

    Examples:
    >>> s = "fabccddg"
    3
    >>> s = "abababaccddb"
    2

    Constraints:
    1 <= s.length <= 1000
    s consists only of English lowercase letters.
    """


Question:
Write a function to check whether the given number is undulating or not.
assert is_undulating("1212121") == True
assert is_undulating("1991") == False
assert is_undulating("121") == True


Question:
Write a function to calculate the sum of the digits of a given number N, and convert this sum to a binary number.
assert solve(1000) == "1"
assert solve(150) == "110"
assert solve(147) == "1100"
assert solve(333) == "1001"
assert solve(963) == "10010"


Question:
Write a function that, for a given number n, find the largest number that divides n evenly, smaller than n.
assert largest_divisor(3) == 1
assert largest_divisor(7) == 1
assert largest_divisor(10) == 5
assert largest_divisor(100) == 50
assert largest_divisor(49) == 7


Question:
def words_in_sentence(sentence):
    """
    You are given a string representing a sentence,
    the sentence contains some words separated by a space,
    and you have to return a string that contains the words from the original sentence,
    whose lengths are prime numbers,
    the order of the words in the new string should be the same as the original one.

    Example 1:
        Input: sentence = "This is a test"
        Output: "is"

    Example 2:
        Input: sentence = "lets go for swimming"
        Output: "go for"

    Constraints:
        * 1 <= len(sentence) <= 100
        * sentence contains only letters
    """


Question:
def find_latest_time(s: str) -> str:
    """
    You are given a string s representing a 12-hour format time where some of the digits (possibly none) are replaced with a "?".

    12-hour times are formatted as "HH:MM", where HH is between 00 and 11, and MM is between 00 and 59. The earliest 12-hour time is 00:00, and the latest is 11:59.

    You have to replace all the "?" characters in s with digits such that the time we obtain by the resulting string is a valid 12-hour format time and is the latest possible.

    Return the resulting string.

    Examples:
    >>> s = "1?:?4"
    "11:54"
    >>> s = "0?:5?"
    "09:59"

    Constraints:
    s.length == 5
    s[2] is equal to the character ":".
    All characters except s[2] are digits or "?" characters.
    The input is generated such that there is at least one time between "00:00" and "11:59" that you can obtain after replacing the "?" characters.
    """


Question:
Write a function to remove empty lists from a given list of lists.
assert remove_empty([[], [], [], 'Red', 'Green', [1,2], 'Blue', [], []])==['Red', 'Green', [1, 2], 'Blue']
assert remove_empty([[], [], [],[],[], 'Green', [1,2], 'Blue', [], []])==[ 'Green', [1, 2], 'Blue']
assert remove_empty([[], [], [], 'Python',[],[], 'programming', 'language',[],[],[], [], []])==['Python', 'programming', 'language']


Question:
from typing import List

def distribute_in_two_arrays(nums: List[int]) -> List[int]:
    """
    You are given a 1-indexed array of distinct integers nums of length n.

    You need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the ith operation:

    If the last element of arr1 is greater than the last element of arr2, append nums[i] to arr1. Otherwise, append nums[i] to arr2.
    The array result is formed by concatenating the arrays arr1 and arr2. For example, if arr1 == [1,2,3] and arr2 == [4,5,6], then result = [1,2,3,4,5,6].

    Return the array result.

    Examples:
    >>> nums = [2,1,3]
    [2,3,1]
    >>> nums = [5,4,3,8]
    [5,3,4,8]

    Constraints:
    3 <= n <= 50
    1 <= nums[i] <= 100
    All elements in nums are distinct.
    """


Question:
Write a function to sort the given array by using counting sort.
assert counting_sort([1,23,4,5,6,7,8]) == [1, 4, 5, 6, 7, 8, 23]
assert counting_sort([12, 9, 28, 33, 69, 45]) == [9, 12, 28, 33, 45, 69]
assert counting_sort([8, 4, 14, 3, 2, 1]) == [1, 2, 3, 4, 8, 14]


Question:
def starts_one_ends(n):
    """
    Given a positive integer n, return the count of the numbers of n-digit
    positive integers that start or end with 1.
    """


Question:
Write a function that takes a list of integers as input, and returns the second smallest element in the list, if it exists. If not, return None.
assert next_smallest([1, 2, 3, 4, 5]) == 2
assert next_smallest([5, 1, 4, 3, 2]) == 2
assert next_smallest([]) == None
assert next_smallest([1, 1]) == None
assert next_smallest([1,1,1,1,0]) == 1
assert next_smallest([1, 0**0]) == None
assert next_smallest([-35, 34, 12, -45]) == -35


Question:
def decimal_to_binary(decimal):
    """You will be given a number in decimal form and your task is to convert it to
    binary format. The function should return a string, with each character representing a binary
    number. Each character in the string will be '0' or '1'.

    There will be an extra couple of characters 'db' at the beginning and at the end of the string.
    The extra characters are there to help with the format.

    Examples:
    decimal_to_binary(15)   # returns "db1111db"
    decimal_to_binary(32)   # returns "db100000db"
    """


Question:
def iscube(a):
    '''
    Write a function that takes an integer a and returns True
    if this ingeger is a cube of some integer number.
    Note: you may assume the input is always valid.
    Examples:
    iscube(1) ==> True
    iscube(2) ==> False
    iscube(-1) ==> True
    iscube(64) ==> True
    iscube(0) ==> True
    iscube(180) ==> False
    '''


Question:
def max_fill(grid, capacity):
    import math
    """
    You are given a rectangular grid of wells. Each row represents a single well,
    and each 1 in a row represents a single unit of water.
    Each well has a corresponding bucket that can be used to extract water from it,
    and all buckets have the same capacity.
    Your task is to use the buckets to empty the wells.
    Output the number of times you need to lower the buckets.

    Example 1:
        Input:
            grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
            bucket_capacity : 1
        Output: 6

    Example 2:
        Input:
            grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
            bucket_capacity : 2
        Output: 5

    Example 3:
        Input:
            grid : [[0,0,0], [0,0,0]]
            bucket_capacity : 5
        Output: 0

    Constraints:
        * all wells have the same length
        * 1 <= grid.length <= 10^2
        * 1 <= grid[:,1].length <= 10^2
        * grid[i][j] -> 0 | 1
        * 1 <= capacity <= 10
    """


Question:
Write a function to remove the parenthesis area in a string.
assert remove_parenthesis(["python (chrome)"])==("python")
assert remove_parenthesis(["string(.abc)"])==("string")
assert remove_parenthesis(["alpha(num)"])==("alpha")


Question:
Write a function special_factorial to compute the Brazilian factorial of an integer. Brazilian factorial is defined as: brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! where n > 0. The function will receive an integer as input and should return the special factorial of this integer.
assert special_factorial(4) == 288
assert special_factorial(5) == 34560
assert special_factorial(7) == 125411328000
assert special_factorial(1) == 1


Question:
def encode(message):
    """
    Write a function that takes a message, and encodes in such a
    way that it swaps case of all letters, replaces all vowels in
    the message with the letter that appears 2 places ahead of that
    vowel in the english alphabet.
    Assume only letters.

    Examples:
    >>> encode('test')
    'TGST'
    >>> encode('This is a message')
    'tHKS KS C MGSSCGG'
    """


Question:
from typing import List
from itertools import accumulate
from math import inf

def max_energy_of_subarrays(nums: List[int], k: int) -> int:
    """
    You are given a 0-indexed array of integers nums of length n, and a positive odd integer k.

    The strength of x subarrays is defined as strength = sum[1] * x - sum[2] * (x - 1) + sum[3] * (x - 2) - sum[4] * (x - 3) + ... + sum[x] * 1 where sum[i] is the sum of the elements in the ith subarray. Formally, strength is sum of (-1)i+1 * sum[i] * (x - i + 1) over all i's such that 1 <= i <= x.

    You need to select k disjoint subarrays from nums, such that their strength is maximum.

    Return the maximum possible strength that can be obtained.

    Note that the selected subarrays don't need to cover the entire array.

    Examples:
    >>> nums = [1,2,3,-1,2], k = 3
    22
    >>> nums = [12,-2,-2,-2,-2], k = 5
    64
    >>> nums = [-1,-2,-3], k = 1
    -1

    Constraints:
    1 <= n <= 10^4
    -10^9 <= nums[i] <= 10^9
    1 <= k <= n
    1 <= n * k <= 10^6
    k is odd.
    """


Question:
Write a function that takes an array of numbers and returns the number of elements in the array that are greater than 10 and both first and last digits of a number are odd (1, 3, 5, 7, 9).
assert specialFilter([5, -2, 1, -5]) == 0
assert specialFilter([15, -73, 14, -15]) == 1
assert specialFilter([33, -2, -3, 45, 21, 109]) == 2
assert specialFilter([43, -12, 93, 125, 121, 109]) == 4
assert specialFilter([71, -2, -33, 75, 21, 19]) == 3
assert specialFilter([1]) == 0
assert specialFilter([]) == 0


Question:
Write a function to find t-nth term of arithemetic progression.
assert tn_ap(1,5,2)==9
assert tn_ap(2,6,4)==22
assert tn_ap(1,4,5)==16


Question:
from typing import List

def unmarked_sum_array(nums: List[int], queries: List[List[int]]) -> List[int]:
    """
    You are given a 0-indexed array nums of size n consisting of positive integers.

    You are also given a 2D array queries of size m where queries[i] = [index_i, k_i].

    Initially all elements of the array are unmarked.

    You need to apply m queries on the array in order, where on the i_th query you do the following:

    Mark the element at index index_i if it is not already marked.
    Then mark k_i unmarked elements in the array with the smallest values. If multiple such elements exist, mark the ones with the smallest indices. And if less than k_i unmarked elements exist, then mark all of them.

    Return an array answer of size m where answer[i] is the sum of unmarked elements in the array after the i th query.

    Examples:
    >>> nums = [1,2,2,1,2,3,1], queries = [[1,2],[3,3],[4,2]]
    [8, 3, 0]
    >>> nums = [1,4,2,3], queries = [[0,1]]
    [7]

    Constraints:
    n == nums.length
    m == queries.length
    1 <= m <= n <= 10^5
    1 <= nums[i] <= 10^5
    queries[i].length == 2
    0 <= index_i, k_i <= n - 1
    """


Question:
def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    >>> truncate_number(3.5)
    0.5
    """


Question:
def even_odd_count(num):
    """Given an integer. return a tuple that has the number of even and odd digits respectively.

     Example:
        even_odd_count(-12) ==> (1, 1)
        even_odd_count(123) ==> (1, 2)
    """


Question:
Write a python function to find the largest postive number from the given list.
assert largest_pos([1,2,3,4,-1]) == 4
assert largest_pos([0,1,2,-5,-1,6]) == 6
assert largest_pos([0,0,1,0]) == 1


Question:
Write a function to sort an array of non-negative integers according to number of ones in their binary representation in ascending order. For similar number of ones, sort based on decimal value.
assert sort_array([1,5,2,3,4]) == [1, 2, 4, 3, 5]
assert sort_array([-2,-3,-4,-5,-6]) == [-4, -2, -6, -5, -3]
assert sort_array([1,0,2,3,4]) == [0, 1, 2, 4, 3]
assert sort_array([]) == []
assert sort_array([2,5,77,4,5,3,5,7,2,3,4]) == [2, 2, 4, 4, 3, 3, 5, 5, 5, 7, 77]
assert sort_array([3,6,44,12,32,5]) == [32, 3, 5, 6, 12, 44]
assert sort_array([2,4,8,16,32]) == [2, 4, 8, 16, 32]
assert sort_array([2,4,8,16,32]) == [2, 4, 8, 16, 32]


Question:
Write a python function to count the number of integral co-ordinates that lie inside a square.
assert count_Intgral_Points(1,1,4,4) == 4
assert count_Intgral_Points(1,2,1,2) == 1
assert count_Intgral_Points(4,2,6,4) == 1


Question:
Write a python function to check whether the hexadecimal number is even or odd.
assert even_or_odd("AB3454D") =="Odd"
assert even_or_odd("ABC") == "Even"
assert even_or_odd("AAD") == "Odd"


Question:
def make_a_pile(n):
    """
    Given a positive integer n, you have to make a pile of n levels of stones.
    The first level has n stones.
    The number of stones in the next level is:
        - the next odd number if n is odd.
        - the next even number if n is even.
    Return the number of stones in each level in a list, where element at index
    i represents the number of stones in the level (i+1).

    Examples:
    >>> make_a_pile(3)
    [3, 5, 7]
    """


Question:
def is_palindrome(string: str) -> bool:
    """ Test if given string is a palindrome """
    return string == string[::-1]

def make_palindrome(string: str) -> str:
    """ Find the shortest palindrome that begins with a supplied string.
    Algorithm idea is simple:
    - Find the longest postfix of supplied string that is a palindrome.
    - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
    >>> make_palindrome('')
    ''
    >>> make_palindrome('cat')
    'catac'
    >>> make_palindrome('cata')
    'catac'
    """


Question:
def split_words(txt):
    '''
    Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
    should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
    alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
    Examples
    split_words("Hello world!") ➞ ["Hello", "world!"]
    split_words("Hello,world!") ➞ ["Hello", "world!"]
    split_words("abcdef") == 3
    '''


Question:
def cycpattern_check(a , b):
    """You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word
    cycpattern_check("abcd","abd") => False
    cycpattern_check("hello","ell") => True
    cycpattern_check("whassup","psus") => False
    cycpattern_check("abab","baa") => True
    cycpattern_check("efef","eeff") => False
    cycpattern_check("himenss","simen") => True

    """


Question:
from typing import List
import bisect
def count_subarrays_with_and_k(nums: List[int], k: int) -> int:
    """
    Given an array of integers nums and an integer k, return the number of
    subarrays
    of nums where the bitwise AND of the elements of the subarray equals k.

    Examples:
    >>> nums = [1,1,1], k = 1
    6
    >>> nums = [1,1,2], k = 1
    3

    Constraints:
    1 <= nums.length <= 10^5
    0 <= nums[i], k <= 10^9
    """


Question:
def min_operations(k: int) -> int:
    """
    You are given a positive integer k. Initially, you have an array nums = [1].

    You can perform any of the following operations on the array any number of times (possibly zero):

    Choose any element in the array and increase its value by 1.
    Duplicate any element in the array and add it to the end of the array.
    Return the minimum number of operations required to make the sum of elements of the final array greater than or equal to k.

    Examples:
    >>> k = 11
    5
    >>> k = 1
    0

    Constraints:
    1 <= k <= 10^5
    """


Question:
from typing import List
from random import randint
from collections import defaultdict
from math import inf
def min_cost_to_make_str(target: str, words: List[str], costs: List[int]) -> int:
    """
    You are given a string target, an array of strings words, and an integer array costs, both arrays of the same length.

    Imagine an empty string s.

    You can perform the following operation any number of times (including zero):

    Choose an index i in the range [0, words.length - 1].
    Append words[i] to s.
    The cost of operation is costs[i].
    Return the minimum cost to make s equal to target. If it's not possible, return -1.

    Examples:
    >>> target = "abcdef", words = ["abdef","abc","d","def","ef"], costs = [100,1,1,10,5]
    7
    >>> target = "aaaa", words = ["z","zz","zzz"], costs = [1,10,100]
    -1

    Constraints:
    1 <= target.length <= 5 * 10^4
    1 <= words.length == costs.length <= 5 * 10^4
    1 <= words[i].length <= target.length
    The total sum of words[i].length is less than or equal to 5 * 10^4.
    target and words[i] consist only of lowercase English letters.
    1 <= costs[i] <= 10^4
    """


Question:
Write a python function to calculate the product of the unique numbers of a given list.
assert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) ==  720000000
assert unique_product([1, 2, 3, 1,]) == 6
assert unique_product([7, 8, 9, 0, 1, 1]) == 0


Question:
Write a function to convert a given string to its md5 hash equivalent string. If the string is empty, return None.
assert string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
assert string_to_md5('') == None
assert string_to_md5('A B C') == '0ef78513b0cb8cef12743f5aeb35f888'
assert string_to_md5('password') == '5f4dcc3b5aa765d61d8327deb882cf99'


Question:
def check_if_last_char_is_a_letter(txt):
    '''
    Create a function that returns True if the last character
    of a given string is an alphabetical character and is not
    a part of a word, and False otherwise.
    Note: "word" is a group of characters separated by space.

    Examples:
    check_if_last_char_is_a_letter("apple pie") ➞ False
    check_if_last_char_is_a_letter("apple pi e") ➞ True
    check_if_last_char_is_a_letter("apple pi e ") ➞ False
    check_if_last_char_is_a_letter("") ➞ False
    '''


Question:
Write a function that accepts a list of strings. The list contains different words. The function should Return the word with maximum number of unique characters. If multiple strings have maximum number of unique characters, return the one which comes first in lexicographical order.
assert (find_max(["name", "of", "string"]) == "string")
assert (find_max(["name", "enam", "game"]) == "enam")
assert (find_max(["aaaaaaa", "bb", "cc"]) == "aaaaaaa")
assert (find_max(["abc", "cba"]) == "abc")
assert (find_max(["play", "this", "game", "of","footbott"]) == "footbott")
assert (find_max(["we", "are", "gonna", "rock"]) == "gonna")
assert (find_max(["we", "are", "a", "mad", "nation"]) == "nation")
assert (find_max(["this", "is", "a", "prrk"]) == "this")
assert (find_max(["b"]) == "b")
assert (find_max(["play", "play", "play"]) == "play")


Question:
from typing import List

def factorize(n: int) -> List[int]:
    """ Return list of prime factors of given integer in the order from smallest to largest.
    Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
    Input number should be equal to the product of all factors
    >>> factorize(8)
    [2, 2, 2]
    >>> factorize(25)
    [5, 5]
    >>> factorize(70)
    [2, 5, 7]
    """


Question:
from typing import List

def work_days_without_meetings(days: int, meetings: List[List[int]]) -> int:
    """
    You are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array meetings of size n where, meetings[i] = [start_i, end_i] represents the starting and ending days of meeting i (inclusive).

    Return the count of days when the employee is available for work but no meetings are scheduled.

    Note that:
    The meetings may overlap.

    Examples:
    >>> days = 10, meetings = [[5,7],[1,3],[9,10]]
    2
    >>> days = 5, meetings = [[2,4],[1,3]]
    1

    Constraints:
    1 <= days <= 10^9
    1 <= meetings.length <= 10^5
    meetings[i].length == 2
    1 <= meetings[i][0] <= meetings[i][1] <= days
    """


Question:
def by_length(arr):
    """
    Given an array of integers, sort the integers that are between 1 and 9 inclusive,
    reverse the resulting array, and then replace each digit by its corresponding name from
    "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".

    For example:
      arr = [2, 1, 1, 4, 5, 8, 2, 3]
            -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8]
            -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]
      return ["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"]

      If the array is empty, return an empty array:
      arr = []
      return []

      If the array has any strange number ignore it:
      arr = [1, -1 , 55]
            -> sort arr -> [-1, 1, 55]
            -> reverse arr -> [55, 1, -1]
      return = ['One']
    """


Question:
Write a function which returns the largest index of an element in the given array that is not greater than or equal to the element immediately preceding it. If no such element exists then the function should return -1. The given array will not contain duplicate values.
assert can_arrange([1,2,4,3,5])==3
assert can_arrange([1,2,4,5])==-1
assert can_arrange([1,4,2,5,6,7,8,9,10])==2
assert can_arrange([4,8,5,7,3])==4
assert can_arrange([])==-1


Question:
Write a function to add two numbers and print number of digits of sum.
assert count_digits(9875,10)==(4)
assert count_digits(98759853034,100)==(11)
assert count_digits(1234567,500)==(7)


Question:
from typing import List

def integer_to_be_added(nums1: List[int], nums2: List[int]) -> int:
    """
    You are given two arrays of equal length, nums1 and nums2.

    Each element in nums1 has been increased (or decreased in the case of negative) by an integer, represented by the variable x.

    As a result, nums1 becomes equal to nums2. Two arrays are considered equal when they contain the same integers with the same frequencies.

    Return the integer x.

    Examples:
    >>> nums1 = [2,6,4], nums2 = [9,7,5]
    3
    >>> nums1 = [10], nums2 = [5]
    -5
    >>> nums1 = [1,1,1,1], nums2 = [1,1,1,1]
    0

    Constraints:
    1 <= nums1.length == nums2.length <= 100
    0 <= nums1[i], nums2[i] <= 1000
    The test cases are generated in a way that there is an integer x such that nums1 can become equal to nums2 by adding x to each element of nums1.
    """


Question:
def common(l1: list, l2: list):
    """Return sorted unique common elements for two lists.
    >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
    [1, 5, 653]
    >>> common([5, 3, 2, 8], [3, 2])
    [2, 3]

    """


Question:
Write a function to remove all whitespaces from the given string using regex.
assert remove_whitespaces(' Google    Flutter ') == 'GoogleFlutter'
assert remove_whitespaces(' Google    Dart ') == 'GoogleDart'
assert remove_whitespaces(' iOS    Swift ') == 'iOSSwift'


Question:
from typing import List

def parse_nested_parens(paren_string: str) -> List[int]:
    """ Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
    For each of the group, output the deepest level of nesting of parentheses.
    E.g. (()()) has maximum two levels of nesting while ((())) has three.

    >>> parse_nested_parens('(()()) ((())) () ((())()())')
    [2, 3, 1, 3]
    """


Question:
def modp(n: int, p: int):
    """Return 2^n modulo p (be aware of numerics).
    >>> modp(3, 5)
    3
    >>> modp(1101, 101)
    2
    >>> modp(0, 101)
    1
    >>> modp(3, 11)
    8
    >>> modp(100, 101)
    1
    """


Question:
Write a python function to find the difference between sum of even and odd digits.
assert is_Diff (12345) == False
assert is_Diff(1212112) == True
assert is_Diff(1212) == False


Question:
Write a function to check if the letters of a given string can be rearranged so that two characters that are adjacent to each other are different.
assert rearange_string("aab")==('aba')
assert rearange_string("aabb")==('abab')
assert rearange_string("abccdd")==('cdabcd')


Question:
Write a function to validate a given date string. The function should return True if the date is valid and False otherwise. The date is valid if it is not empty, the number of days and months are within the correct range, and the date is in the 'mm-dd-yyyy' format.
assert valid_date('03-11-2000') == True
assert valid_date('15-01-2012') == False
assert valid_date('04-0-2040') == False
assert valid_date('06-04-2020') == True
assert valid_date('01-01-2007') == True
assert valid_date('03-32-2011') == False
assert valid_date('') == False
assert valid_date('04-31-3000') == False
assert valid_date('06-06-2005') == True
assert valid_date('21-31-2000') == False
assert valid_date('04-12-2003') == True
assert valid_date('04122003') == False
assert valid_date('20030412') == False
assert valid_date('2003-04') == False
assert valid_date('2003-04-12') == False
assert valid_date('04-2003') == False


Question:
from typing import List
from collections import Counter

def can_make_square(grid: List[List[str]]) -> bool:
    """
    You are given a 2D matrix grid of size 3 x 3 consisting only of characters 'B' and 'W'. Character 'W' represents the white color, and character 'B' represents the black color.

    Your task is to change the color of at most one cell so that the matrix has a 2 x 2 square where all cells are of the same color.

    Return true if it is possible to create a 2 x 2 square of the same color, otherwise, return false.

    Examples:
    >>> grid = [["B","W","B"],["B","W","W"],["B","W","B"]]
    true
    >>> grid = [["B","W","B"],["W","B","W"],["B","W","B"]]
    false
    >>> grid = [["B","W","B"],["B","W","W"],["B","W","W"]]
    true

    Constraints:
    grid.length == 3
    grid[i].length == 3
    grid[i][j] is either 'W' or 'B'.
    """


Question:
Write a function to find the list of lists with maximum length.
assert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])
assert max_length([[1], [5, 7], [10, 12, 14,15]])==(4, [10, 12, 14,15])
assert max_length([[5], [15,20,25]])==(3, [15,20,25])


Question:
Write a function to find the area of a rectangle.
assert rectangle_area(10,20)==200
assert rectangle_area(10,5)==50
assert rectangle_area(4,2)==8


Question:
Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.
assert sum_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==48
assert sum_positivenum([10,15,-14,13,-18,12,-20])==50
assert sum_positivenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==522


Question:
Write a function to find the n-th rectangular number.
assert find_rect_num(4) == 20
assert find_rect_num(5) == 30
assert find_rect_num(6) == 42


Question:
from typing import List

def is_possible_to_split(nums: List[int]) -> bool:
    """
    You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:

    nums1.length == nums2.length == nums.length / 2.
    nums1 should contain distinct elements.
    nums2 should also contain distinct elements.

    Return true if it is possible to split the array, and false otherwise.

    Examples:
    >>> nums = [1,1,2,2,3,4]
    true
    >>> nums = [1,1,1,1]
    false

    Constraints:
    1 <= nums.length <= 100
    nums.length % 2 == 0
    1 <= nums[i] <= 100
    """


Question:
Write a python function to merge the first and last elements separately in a list of lists.
assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]
assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]
assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]


Question:
from typing import List

def number_of_alternating_groups(colors: List[int]) -> int:
    """
    There is a circle of red and blue tiles. You are given an array of integers colors. The color of tile i is represented by colors[i]:

    colors[i] == 0 means that tile i is red.
    colors[i] == 1 means that tile i is blue.
    Every 3 contiguous tiles in the circle with alternating colors (the middle tile has a different color from its left and right tiles) is called an alternating group.

    Return the number of alternating groups.

    Note that:
     since colors represents a circle, the first and the last tiles are considered to be next to each other.

    Examples:
    >>> colors = [1,1,1]
    0
    >>> colors = [0,1,0,0,1]
    3

    Constraints:
    3 <= colors.length <= 100
    0 <= colors[i] <= 1
    """


Question:
Write a function that returns true if the given number is the multiplication of 3 prime numbers and false otherwise, knowing that the given number is less than 100.
assert is_multiply_prime(5) == False
assert is_multiply_prime(30) == True
assert is_multiply_prime(8) == True
assert is_multiply_prime(10) == False
assert is_multiply_prime(125) == True
assert is_multiply_prime(3 * 5 * 7) == True
assert is_multiply_prime(3 * 6 * 7) == False
assert is_multiply_prime(9 * 9 * 9) == False
assert is_multiply_prime(11 * 9 * 9) == False
assert is_multiply_prime(11 * 13 * 7) == True


Question:
Write a python function to find the first natural number whose factorial is divisible by x.
assert first_Factorial_Divisible_Number(10) == 5
assert first_Factorial_Divisible_Number(15) == 5
assert first_Factorial_Divisible_Number(5) == 4


Question:
from typing import List

def maximum_total_cost(nums: List[int]) -> int:
    """
    You are given an integer array nums with length n.

    The cost of a subarray
    nums[l..r], where 0 <= l <= r < n, is defined as:

    cost(l, r) = nums[l] - nums[l + 1] + ... + nums[r] * (−1)^(r − l)

    Your task is to split nums into subarrays such that the total cost of the subarrays is maximized, ensuring each element belongs to exactly one subarray.

    Formally, if nums is split into k subarrays, where k > 1, at indices i_1, i_2, ..., i_k − 1, where 0 <= i_1 < i_2 < ... < i_k - 1 < n - 1, then the total cost will be:

    cost(0, i_1) + cost(i_1 + 1, i_2) + ... + cost(i_k − 1 + 1, n − 1)

    Return an integer denoting the maximum total cost of the subarrays after splitting the array optimally.
    Note that:
     If nums is not split into subarrays, i.e. k = 1, the total cost is simply cost(0, n - 1).

    Examples:
    >>> nums = [1,-2,3,4]
    10
    >>> nums = [1,-1,1,-1]
    4

    Constraints:
    1 <= nums.length <= 10^5
    -10^9 <= nums[i] <= 10^9
    """


Question:
from typing import List

def min_subarray_length(nums: List[int], k: int) -> int:
    """
    You are given an array nums of non-negative integers and an integer k.

    An array is called special if the bitwise OR of all of its elements is at least k.

    Return the length of the shortest special non-empty
    subarray of nums, or return -1 if no special subarray exists.

    Examples:
    >>> nums = [1,2,3], k = 2
    1
    >>> nums = [2,1,8], k = 10
    3
    >>> nums = [1,2], k = 0
    1

    Constraints:
    1 <= nums.length <= 50
    0 <= nums[i] <= 50
    0 <= k < 64
    """


Question:
Write a function that matches a string that has an a followed by zero or one 'b'.
assert text_match_zero_one("ac")==('Found a match!')
assert text_match_zero_one("dc")==('Not matched!')
assert text_match_zero_one("abbbba")==('Found a match!')


Question:
from typing import List
from collections import Counter
from heapq import heappush, heappop
def most_frequent_ids(nums: List[int], freq: List[int]) -> List[int]:
    """
    The problem involves tracking the frequency of IDs in a collection that changes over time. You have two integer arrays, nums and freq, of equal length n. Each element in nums represents an ID, and the corresponding element in freq indicates how many times that ID should be added to or removed from the collection at each step.

    Addition of IDs: If freq[i] is positive, it means freq[i] IDs with the value nums[i] are added to the collection at step i.
    Removal of IDs: If freq[i] is negative, it means -freq[i] IDs with the value nums[i] are removed from the collection at step i.
    Return an array ans of length n, where ans[i] represents the count of the most frequent ID in the collection after the ith step. If the collection is empty at any step, ans[i] should be 0 for that step.

    Examples:
    >>> nums = [2,3,2,1], freq = [3,2,-3,1]
    [3,3,2,2]
    >>> nums = [5,5,3], freq = [2,-2,1]
    [2,0,1]

    Constraints:
    1 <= nums.length == freq.length <= 10^5
    1 <= nums[i] <= 10^5
    -10^5 <= freq[i] <= 10^5
    freq[i] != 0
    The input is generated such that the occurrences of an ID will not be negative in any step.
    """


Question:
def sort_third(l: list):
    """This function takes a list l and returns a list l' such that
    l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
    to the values of the corresponding indicies of l, but sorted.
    >>> sort_third([1, 2, 3])
    [1, 2, 3]
    >>> sort_third([5, 6, 3, 4, 8, 9, 2])
    [2, 6, 3, 4, 8, 9, 5]
    """


Question:
Write a python function to count occurences of a character in a repeated string.
assert count_Char("abcac",'a') == 4
assert count_Char("abca",'c') == 2
assert count_Char("aba",'a') == 7


Question:
from typing import List

def max_selected_elements(nums: List[int]) -> int:
    """
    You are given a 0-indexed array nums consisting of positive integers.

    Initially, you can increase the value of any element in the array by at most 1.

    After that, you need to select one or more elements from the final array such that those elements are consecutive when sorted in increasing order. For example, the elements [3, 4, 5] are consecutive while [3, 4, 6] and [1, 1, 2, 3] are not.

    Return the maximum number of elements that you can select.

    Examples:
    >>> nums = [2,1,5,1,1]
    3
    >>> nums = [1,4,7,10]
    1

    Constraints:
    1 <= nums.length <= 10^5
    1 <= nums[i] <= 10^6
    """


Question:
Write a function to display sign of the chinese zodiac for given year.
assert chinese_zodiac(1997)==('Ox')
assert chinese_zodiac(1998)==('Tiger')
assert chinese_zodiac(1994)==('Dog')


Question:
Write a python function to count numbers whose oth and nth bits are set.
assert count_Num(2) == 1
assert count_Num(3) == 2
assert count_Num(1) == 1


Question:
def sum_of_digits_of_harshad_number(x: int) -> int:
    """
    An integer divisible by the sum of its digits is said to be a Harshad number. You are given an integer x. Return the sum of the digits of x if x is a Harshad number, otherwise, return -1.

    Examples:
    >>> x = 18
    9
    >>> x = 23
    -1

    Constraints:
    1 <= x <= 100
    """


Question:
Write a function to search some literals strings in a string.
assert string_literals(['language'],'python language')==('Matched!')
assert string_literals(['program'],'python language')==('Not Matched!')
assert string_literals(['python'],'programming language')==('Not Matched!')


Question:
Write a function to find the list with maximum length using lambda function.
assert max_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])
assert max_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(5,[1,2,3,4,5])
assert max_length_list([[3,4,5],[6,7,8,9],[10,11,12]])==(4,[6,7,8,9])


Question:
Write a function to sort a list of dictionaries using lambda function.
assert sorted_models([{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':2, 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}])==[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': 2, 'color': 'Gold'}]
assert sorted_models([{'make':'Vivo', 'model':20,'color':'Blue'},{'make': 'oppo','model':17,'color':'Gold'},{'make':'Apple','model':11,'color':'red'}])==([{'make':'Vivo', 'model':20,'color':'Blue'},{'make': 'oppo','model':17,'color':'Gold'},{'make':'Apple','model':11,'color':'red'}])
assert sorted_models([{'make':'micromax','model':40,'color':'grey'},{'make':'poco','model':60,'color':'blue'}])==([{'make':'poco','model':60,'color':'blue'},{'make':'micromax','model':40,'color':'grey'}])


Question:
Write a python function to find the first repeated character in a given string.
assert first_repeated_char("abcabc") == "a"
assert first_repeated_char("abc") == "None"
assert first_repeated_char("123123") == "1"


Question:
from typing import List

def max_score_after_battle(enemyEnergies: List[int], currentEnergy: int) -> int:
    """
    You are given an integer array enemyEnergies denoting the energy values of various enemies.

    You are also given an integer currentEnergy denoting the amount of energy you have initially.

    You start with 0 points, and all the enemies are unmarked initially.

    You can perform either of the following operations zero or multiple times to gain points:

    Choose an unmarked enemy, i, such that currentEnergy >= enemyEnergies[i]. By choosing this option:
    You gain 1 point.
    Your energy is reduced by the enemy's energy, i.e. currentEnergy = currentEnergy - enemyEnergies[i].
    If you have at least 1 point, you can choose an unmarked enemy, i. By choosing this option:
    Your energy increases by the enemy's energy, i.e. currentEnergy = currentEnergy + enemyEnergies[i].
    The enemy i is marked.
    Return an integer denoting the maximum points you can get in the end by optimally performing operations.

    Examples:
    >>> enemyEnergies = [3,2,2], currentEnergy = 2
    3
    >>> enemyEnergies = [2], currentEnergy = 10
    5

    Constraints:
    1 <= enemyEnergies.length <= 10^5
    1 <= enemyEnergies[i] <= 10^9
    0 <= currentEnergy <= 10^9
    """


Question:
from typing import List

def below_zero(operations: List[int]) -> bool:
    """ You're given a list of deposit and withdrawal operations on a bank account that starts with
    zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
    at that point function should return True. Otherwise it should return False.
    >>> below_zero([1, 2, 3])
    False
    >>> below_zero([1, 2, -4, 5])
    True
    """


Question:
Write a function to calculate the minimum number of elements that need to be changed to make an array of integers palindromic. A palindromic array is an array that is read the same backwards and forwards. You may change one element to any other element in one change.
assert smallest_change([1,2,3,5,4,7,9,6]) == 4
assert smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
assert smallest_change([1, 4, 2]) == 1
assert smallest_change([1, 4, 4, 2]) == 1
assert smallest_change([1, 2, 3, 2, 1]) == 0
assert smallest_change([3, 1, 1, 3]) == 0
assert smallest_change([1]) == 0
assert smallest_change([0, 1]) == 1


Question:
from typing import List
from itertools import pairwise
def translate_queries(queries: List[List[int]]) -> List[bool]:
    """
    There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.

    You are given a 2D array queries, which contains two types of queries:

    1.For a query of type 1, queries[i] = [1, x]. Build an obstacle at distance x from the origin. It is guaranteed that there is no obstacle at distance x when the query is asked.
    2.For a query of type 2, queries[i] = [2, x, sz]. Check if it is possible to place a block of size sz anywhere in the range [0, x] on the line, such that the block entirely lies in the range [0, x]. A block cannot be placed if it intersects with any obstacle, but it may touch it. Note that you do not actually place the block. Queries are separate.
    Return a boolean array results, where results[i] is true if you can place the block specified in the ith query of type 2, and false otherwise.

    Examples:
    >>> queries = [[1,2],[2,3,3],[2,3,1],[2,2,2]]
    [false,true,true]
    >>> queries = [[1,7],[2,7,6],[1,2],[2,7,5],[2,7,6]]
    [true,true,false]

    Constraints:
    1 <= queries.length <= 15 * 10^4
    2 <= queries[i].length <= 3
    1 <= queries[i][0] <= 2
    1 <= x, sz <= min(5 * 10^4, 3 * queries.length)
    The input is generated such that for queries of type 1, no obstacle exists at distance x when the query is asked.
    The input is generated such that there is at least one query of type 2.
    """


Question:
from typing import List
from math import inf

def max_node_value_sum(nums: List[int], k: int, edges: List[List[int]]) -> int:
    """
    There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 0-indexed 2D integer array edges of length n - 1, where edges[i] = [u_i, v_i] indicates that there is an edge between nodes u_i and v_i in the tree. You are also given a positive integer k, and a 0-indexed array of non-negative integers nums of length n, where nums[i] represents the value of the node numbered i.

    Alice wants the sum of values of tree nodes to be maximum, for which Alice can perform the following operation any number of times (including zero) on the tree:

    Choose any edge [u, v] connecting the nodes u and v, and update their values as follows:
    nums[u] = nums[u] XOR k
    nums[v] = nums[v] XOR k
    Return the maximum possible sum of the values Alice can achieve by performing the operation any number of times.

    Examples:
    >>> nums = [1,2,1], k = 3, edges = [[0,1],[0,2]]
    6
    >>> nums = [2,3], k = 7, edges = [[0,1]]
    9
    >>> nums = [7,7,7,7,7,7], k = 3, edges = [[0,1],[0,2],[0,3],[0,4],[0,5]]
    42

    Constraints:
    2 <= n == nums.length <= 2 * 10^4
    1 <= k <= 10^9
    0 <= nums[i] <= 10^9
    edges.length == n - 1
    edges[i].length == 2
    0 <= edges[i][0], edges[i][1] <= n - 1
    The input is generated such that edges represent a valid tree.
    """


Question:
from typing import List, Tuple

def sum_product(numbers: List[int]) -> Tuple[int, int]:
    """ For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
    Empty sum should be equal to 0 and empty product should be equal to 1.
    >>> sum_product([])
    (0, 1)
    >>> sum_product([1, 2, 3, 4])
    (10, 24)
    """


Question:
Write a function to calculate the number of collisions when n cars are moving from left to right and another n cars are moving from right to left on a perfectly straight indefinitely long road where all cars move at the same speed. The cars are infinitely sturdy and continue moving in their trajectory even after they collide.
assert car_race_collision(2) == 4
assert car_race_collision(3) == 9
assert car_race_collision(4) == 16
assert car_race_collision(8) == 64
assert car_race_collision(10) == 100


Question:
Write a function to find n-th rencontres number.
assert rencontres_number(7, 2) == 924
assert rencontres_number(3, 0) == 2
assert rencontres_number(3, 1) == 3


Question:
def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """


Question:
Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.
assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243
assert round_and_sum([5,2,9,24.3,29])==345
assert round_and_sum([25.0,56.7,89.2])==513


Question:
Write a function that gives loss amount if the given amount has loss else return none.
assert loss_amount(1500,1200)==None
assert loss_amount(100,200)==100
assert loss_amount(2000,5000)==3000


Question:
def triangle_area(a, h):
    """Given length of a side and high return area for a triangle.
    >>> triangle_area(5, 3)
    7.5
    """


Question:
def compare_one(a, b):
    """
    Create a function that takes integers, floats, or strings representing
    real numbers, and returns the larger variable in its given variable type.
    Return None if the values are equal.
    Note: If a real number is represented as a string, the floating point might be . or ,

    compare_one(1, 2.5) ➞ 2.5
    compare_one(1, "2,3") ➞ "2,3"
    compare_one("5,1", "6") ➞ "6"
    compare_one("1", 1) ➞ None
    """


Question:
def anti_shuffle(s):
    """
    Write a function that takes a string and returns an ordered version of it.
    Ordered version of string, is a string where all words (separated by space)
    are replaced by a new word where all the characters arranged in
    ascending order based on ascii value.
    Note: You should keep the order of words and blank spaces in the sentence.

    For example:
    anti_shuffle('Hi') returns 'Hi'
    anti_shuffle('hello') returns 'ehllo'
    anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
    """


Question:
Write a function to extract specified size of strings from a give list of string values.
assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']
assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']
assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']


Question:
Write a function to find whether a given array of integers contains any duplicate element.
assert test_duplicate(([1,2,3,4,5]))==False
assert test_duplicate(([1,2,3,4, 4]))==True
assert test_duplicate([1,1,2,2,3,3,4,4,5])==True


Question:
Write a function to reverse strings in a given list of string values.
assert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']
assert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg']
assert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']


Question:
def x_or_y(n, x, y):
    """A simple program which should return the value of x if n is
    a prime number and should return the value of y otherwise.

    Examples:
    for x_or_y(7, 34, 12) == 34
    for x_or_y(15, 8, 5) == 5

    """


Question:
Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.
assert sort_dict_item({(5, 6) : 3, (2, 3) : 9, (8, 4): 10, (6, 4): 12} ) == {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}
assert sort_dict_item({(6, 7) : 4, (3, 4) : 10, (9, 5): 11, (7, 5): 13} ) == {(3, 4): 10, (7, 5): 13, (6, 7): 4, (9, 5): 11}
assert sort_dict_item({(7, 8) : 5, (4, 5) : 11, (10, 6): 12, (8, 6): 14} ) == {(4, 5): 11, (8, 6): 14, (7, 8): 5, (10, 6): 12}


Question:
from typing import List, Tuple

def count_pairs_of_connectable_servers(edges: List[Tuple[int, int, int]], signalSpeed: int) -> List[int]:
    """
    You are given an unrooted weighted tree with n vertices representing servers numbered from 0 to n - 1, an array edges where edges[i] = [a_i, b_i, weighti] represents a bidirectional edge between vertices a_i and b_i of weight weight_i. You are also given an integer signalSpeed.

    Two servers a and b are connectable through a server c if:

    a < b, a != c and b != c.
    The distance from c to a is divisible by signalSpeed.
    The distance from c to b is divisible by signalSpeed.
    The path from c to b and the path from c to a do not share any edges.
    Return an integer array count of length n where count[i] is the number of server pairs that are connectable through the server i.

    Examples:
    >>> edges = [[0,1,1],[1,2,5],[2,3,13],[3,4,9],[4,5,2]], signalSpeed = 1
    [0,4,6,6,4,0]
    >>> edges = [[0,6,3],[6,5,3],[0,3,1],[3,2,7],[3,1,6],[3,4,2]], signalSpeed = 3
    [2,0,0,0,0,0,2]

    Constraints:
    2 <= n <= 1000
    edges.length == n - 1
    edges[i].length == 3
    0 <= a_i, b_i < n
    edges[i] = [a_i, b_i, weight_i]
    1 <= weight_i <= 10^6
    1 <= signalSpeed <= 10^6
    The input is generated such that edges represents a valid tree.
    """


Question:
Write a function to count those characters which have vowels as their neighbors in the given string.
assert count_vowels('bestinstareels') == 7
assert count_vowels('partofthejourneyistheend') == 12
assert count_vowels('amazonprime') == 5


Question:
Write a function to accept a list of strings, deleting the items with odd lengths and returning the list sorted in ascending order first by the length of each item, then alphabetically if the lengths match.
assert sorted_list_sum(["aa", "a", "aaa"]) == ["aa"]
assert sorted_list_sum(["school", "AI", "asdf", "b"]) == ["AI", "asdf", "school"]
assert sorted_list_sum(["d", "b", "c", "a"]) == []
assert sorted_list_sum(["d", "dcba", "abcd", "a"]) == ["abcd", "dcba"]
assert sorted_list_sum(["AI", "ai", "au"]) == ["AI", "ai", "au"]
assert sorted_list_sum(["a", "b", "b", "c", "c", "a"]) == []
assert sorted_list_sum(['aaaa', 'bbbb', 'dd', 'cc']) == ["cc", "dd", "aaaa", "bbbb"]


Question:
def greatest_common_divisor(a: int, b: int) -> int:
    """ Return a greatest common divisor of two integers a and b
    >>> greatest_common_divisor(3, 5)
    1
    >>> greatest_common_divisor(25, 15)
    5
    """


Question:
from typing import List

def min_operations_to_divisible_by_three(nums: List[int]) -> int:
    """
    You are given an integer array nums. In one operation, you can add or subtract 1 from any element of nums.

    Return the minimum number of operations to make all elements of nums divisible by 3.

    Examples:
    >>> nums = [1,2,3,4]
    3
    >>> nums = [3,6,9]
    0

    Constraints:
    1 <= nums.length <= 50
    1 <= nums[i] <= 50
    """


Question:
Write a function to remove the duplicates from the given tuple.
assert remove_tuple((1, 3, 5, 2, 3, 5, 1, 1, 3)) == (1, 2, 3, 5)
assert remove_tuple((2, 3, 4, 4, 5, 6, 6, 7, 8, 8)) == (2, 3, 4, 5, 6, 7, 8)
assert remove_tuple((11, 12, 13, 11, 11, 12, 14, 13)) == (11, 12, 13, 14)


Question:
Write a python function to find the sum of xor of all pairs of numbers in the given array.
assert pair_OR_Sum([5,9,7,6],4) == 47
assert pair_OR_Sum([7,3,5],3) == 12
assert pair_OR_Sum([7,3],2) == 4


Question:
def encode_shift(s: str):
    """
    returns encoded string by shifting every character by 5 in the alphabet.
    """
    return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])

def decode_shift(s: str):
    """
    takes as input string encoded with encode_shift function. Returns decoded string.
    """


Question:
Write a function to return the number of times the digit 7 appears in integers less than a given number which are divisible by 11 or 13.
assert fizz_buzz(50) == 0
assert fizz_buzz(78) == 2
assert fizz_buzz(79) == 3
assert fizz_buzz(100) == 3
assert fizz_buzz(200) == 6
assert fizz_buzz(4000) == 192
assert fizz_buzz(10000) == 639
assert fizz_buzz(100000) == 8026


Question:
Write a python function to interchange first and last elements in a given list.
assert swap_List([1,2,3]) == [3,2,1]
assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]
assert swap_List([4,5,6]) == [6,5,4]


Question:
Write a function to find the list with minimum length using lambda function.
assert min_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(1, [0])
assert min_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(1,[1])
assert min_length_list([[3,4,5],[6,7,8,9],[10,11,12],[1,2]])==(2,[1,2])


Question:
Write a python function to split the array and add the first part to the end.
assert split_Arr([12,10,5,6,52,36],6,2) == [5,6,52,36,12,10]
assert split_Arr([1,2,3,4],4,1) == [2,3,4,1]
assert split_Arr([0,1,2,3,4,5,6,7],8,3) == [3,4,5,6,7,0,1,2]


Question:
Write a python function to copy a list from a singleton tuple.
assert lcopy([1, 2, 3]) == [1, 2, 3]
assert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]
assert lcopy([4, 5, 6]) == [4, 5, 6]


Question:
def sort_array(array):
    """
    Given an array of non-negative integers, return a copy of the given array after sorting,
    you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
    or sort it in descending order if the sum( first index value, last index value) is even.

    Note:
    * don't change the given array.

    Examples:
    * sort_array([]) => []
    * sort_array([5]) => [5]
    * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
    * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
    """


Question:
Write a function to count total characters in a string.
assert count_charac("python programming")==18
assert count_charac("language")==8
assert count_charac("words")==5


Question:
def max_partitions_after_operations(s: str, k: int) -> int:
    """
    You are given a string s and an integer k.

    First, you are allowed to change at most one index in s to another lowercase English letter.

    After that, do the following partitioning operation until s is empty:

    Choose the longest prefix of s containing at most k distinct characters.
    Delete the prefix from s and increase the number of partitions by one. The remaining characters (if any) in s maintain their initial order.
    Return an integer denoting the maximum number of resulting partitions after the operations by optimally choosing at most one index to change.

    Examples:
    >>> s = "accca", k = 2
    3
    >>> s = "aabaab", k = 3
    1
    >>> s = "xxyz", k = 1
    4

    Constraints:
    1 <= s.length <= 10^4
    s consists only of lowercase English letters.
    1 <= k <= 26
    """


Question:
from typing import List

def number_of_pairs(points: List[List[int]]) -> int:
    """
    You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].

    Count the number of pairs of points (A, B), where A is on the upper left side of B, and there are no other points in the rectangle (or line) they make (including the border).

    Return the count.

    Examples:
    >>> points = [[1,1],[2,2],[3,3]]
    0
    >>> points = [[6,2],[4,4],[2,6]]
    2
    >>> points = [[3,1],[1,3],[1,1]]
    2

    Constraints:
    2 <= n <= 50
    points[i].length == 2
    0 <= points[i][0], points[i][1] <= 50
    All points[i] are distinct.
    """


Question:
from typing import List
from collections import defaultdict

def count_prefix_suffix_pairs(words: List[str]) -> int:
    """
    You are given a 0-indexed string array words.

    Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:

    isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.
    For example, isPrefixAndSuffix("aba", "ababa") is true because "aba" is a prefix of "ababa" and also a suffix, but isPrefixAndSuffix("abc", "abcd") is false.

    Return an integer denoting the number of index pairs (i, j) such that i < j, and isPrefixAndSuffix(words[i], words[j]) is true.

    Examples:
    >>> words = ["a","aba","ababa","aa"]
    4
    >>> words = ["pa","papa","ma","mama"]
    2
    >>> words = ["abab","ab"]
    0

    Constraints:
    1 <= words.length <= 10^5
    1 <= words[i].length <= 10^5
    words[i] consists only of lowercase English letters.
    The sum of the lengths of all words[i] does not exceed 5 * 10^5.
    """


Question:
def check_for_same_substring(s: str) -> bool:
    """
    Given a string s, find any substring of length 2 which is also present in the reverse of s.

    Return true if such a substring exists, and false otherwise.

    Examples:
    >>> s = "leetcode"
    true
    >>> s = "abcba"
    true
    >>> s = "abcd"
    false

    Constraints:
    1 <= s.length <= 100
    s consists only of lowercase English letters.
    """


Question:
Write a function to check if a given number is prime or not.
assert is_prime(6) == False
assert is_prime(101) == True
assert is_prime(11) == True
assert is_prime(13441) == True
assert is_prime(61) == True
assert is_prime(4) == False
assert is_prime(1) == False
assert is_prime(5) == True
assert is_prime(11) == True
assert is_prime(17) == True
assert is_prime(5 * 17) == False
assert is_prime(11 * 7) == False
assert is_prime(13441 * 19) == False


Question:
Write a function to find the largest possible value of k such that k modulo x is y.
assert find_max_val(15, 10, 5) == 15
assert find_max_val(187, 10, 5) == 185
assert find_max_val(16, 11, 1) == 12


Question:
Write a function to find n’th smart number.
assert smartNumber(1) == 30
assert smartNumber(50) == 273
assert smartNumber(1000) == 2664


Question:
from typing import List

def find_index_of_occurrences(nums: List[int], queries: List[int], x: int) -> List[int]:
    """
    You are given an integer array nums, an integer array queries, and an integer x.

    For each queries[i], you need to find the index of the queries[i]_th occurrence of x in the nums array. If there are fewer than queries[i] occurrences of x, the answer should be -1 for that query.

    Return an integer array answer containing the answers to all queries.

    Examples:
    >>> nums = [1,3,1,7], queries = [1,3,2,4], x = 1
    [0,-1,2,-1]
    >>> nums = [1,2,3], queries = [10], x = 5
    [-1]

    Constraints:
    1 <= nums.length, queries.length <= 10^5
    1 <= queries[i] <= 10^5
    1 <= nums[i], x <= 10^4
    """


Question:
Write a python function to find the last two digits in factorial of a given number.
assert last_Two_Digits(7) == 40
assert last_Two_Digits(5) == 20
assert last_Two_Digits(2) == 2


Question:
from typing import List

def min_operations_to_write_y(grid: List[List[int]]) -> int:
    """
    You are given a 0-indexed n x n grid where n is odd, and grid[r][c] is 0, 1, or 2.

    We say that a cell belongs to the Letter Y if it belongs to one of the following:

    The diagonal starting at the top-left cell and ending at the center cell of the grid.
    The diagonal starting at the top-right cell and ending at the center cell of the grid.
    The vertical line starting at the center cell and ending at the bottom border of the grid.
    The Letter Y is written on the grid if and only if:

    All values at cells belonging to the Y are equal.
    All values at cells not belonging to the Y are equal.
    The values at cells belonging to the Y are different from the values at cells not belonging to the Y.
    Return the minimum number of operations needed to write the letter Y on the grid given that in one operation you can change the value at any cell to 0, 1, or 2.

    Examples:
    >>> grid = [[1,2,2],[1,1,0],[0,1,0]]
    3
    >>> grid = [[0,1,0,1,0],[2,1,0,1,2],[2,2,2,0,1],[2,2,2,2,2],[2,1,2,2,2]]
    12

    Constraints:
    3 <= n <= 49
    n == grid.length == grid[i].length
    0 <= grid[i][j] <= 2
    n is odd.
    """


Question:
Write a function to sort a tuple by its float element.
assert float_sort([('item1', '12.20'), ('item2', '15.10'), ('item3', '24.5')])==[('item3', '24.5'), ('item2', '15.10'), ('item1', '12.20')]
assert float_sort([('item1', '15'), ('item2', '10'), ('item3', '20')])==[('item3', '20'), ('item1', '15'), ('item2', '10')]
assert float_sort([('item1', '5'), ('item2', '10'), ('item3', '14')])==[('item3', '14'), ('item2', '10'), ('item1', '5')]


Question:
Write a function to find the minimum sum of any non-empty subarray from an array of integers.
assert minSubArraySum([2, 3, 4, 1, 2, 4]) == 1
assert minSubArraySum([-1, -2, -3]) == -6
assert minSubArraySum([-1, -2, -3, 2, -10]) == -14
assert minSubArraySum([-9999999999999999]) == -9999999999999999
assert minSubArraySum([0, 10, 20, 1000000]) == 0
assert minSubArraySum([-1, -2, -3, 10, -5]) == -6
assert minSubArraySum([100, -1, -2, -3, 10, -5]) == -6
assert minSubArraySum([10, 11, 13, 8, 3, 4]) == 3
assert minSubArraySum([100, -33, 32, -1, 0, -2]) == -33
assert minSubArraySum([-10]) == -10
assert minSubArraySum([7]) == 7
assert minSubArraySum([1, -1]) == -1


Question:
Write a python function to find highest power of 2 less than or equal to given number.
assert highest_Power_of_2(10) == 8
assert highest_Power_of_2(19) == 16
assert highest_Power_of_2(32) == 32


Question:
from typing import List

def shortest_substrings(arr: List[str]) -> List[str]:
    """
    You are given an array arr of size n consisting of non-empty strings.

    Find a string array answer of size n such that:

    answer[i] is the shortest substring of arr[i] that does not occur as a substring in any other string in arr. If multiple such substrings exist, answer[i] should be the lexicographically smallest. And if no such substring exists, answer[i] should be an empty string.

    Return the array answer.

    Examples:
    >>> arr = ["cab","ad","bad","c"]
    ["ab","","ba",""]
    >>> arr = ["abc","bcd","abcd"]
    ["","","abcd"]

    Constraints:
    n == arr.length
    2 <= n <= 100
    1 <= arr[i].length <= 20
    arr[i] consists only of lowercase English letters.
    """


Question:
Write a function to calculate the discriminant value.
assert discriminant_value(4,8,2)==("Two solutions",32)
assert discriminant_value(5,7,9)==("no real solution",-131)
assert discriminant_value(0,0,9)==("one solution",0)


Question:
Write a function to substaract two lists using map and lambda function.
assert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]
assert sub_list([1,2],[3,4])==[-2,-2]
assert sub_list([90,120],[50,70])==[40,50]


Question:
def order_by_points(nums):
    """
    Write a function which sorts the given list of integers
    in ascending order according to the sum of their digits.
    Note: if there are several items with similar sum of their digits,
    order them based on their index in original list.

    For example:
    >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]
    >>> order_by_points([]) == []
    """


Question:
def reverse_delete(s,c):
    """Task
    We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
    then check if the result string is palindrome.
    A string is called palindrome if it reads the same backward as forward.
    You should return a tuple containing the result string and True/False for the check.
    Example
    For s = "abcde", c = "ae", the result should be ('bcd',False)
    For s = "abcdef", c = "b"  the result should be ('acdef',False)
    For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
    """


Question:
Write a function to replace all spaces in a given string with underscores, and if a string has more than 2 consecutive spaces, then replace all consecutive spaces with -.
assert fix_spaces("Example") == "Example"
assert fix_spaces("Mudasir Hanif ") == "Mudasir_Hanif_"
assert fix_spaces("Yellow Yellow  Dirty  Fellow") == "Yellow_Yellow__Dirty__Fellow"
assert fix_spaces("Exa   mple") == "Exa-mple"
assert fix_spaces("   Exa 1 2 2 mple") == "-Exa_1_2_2_mple"


Question:
Write a python function to find the cube sum of first n odd natural numbers.
assert cube_Sum(2) == 28
assert cube_Sum(3) == 153
assert cube_Sum(4) == 496


Question:
def count_distinct_characters(string: str) -> int:
    """ Given a string, find out how many distinct characters (regardless of case) does it consist of
    >>> count_distinct_characters('xyzXYZ')
    3
    >>> count_distinct_characters('Jerry')
    4
    """


Question:
Write a function to convert radians to degrees.
assert degree_radian(90)==5156.620156177409
assert degree_radian(60)==3437.746770784939
assert degree_radian(120)==6875.493541569878


Question:
from typing import List
from functools import lru_cache as cache
def number_of_permutations(n: int, requirements: List[List[int]]) -> int:
    """
    You are given an integer n and a 2D array requirements, where requirements[i] = [end_i, cnt_i] represents the end index and the inversion count of each requirement.

    A pair of indices (i, j) from an integer array nums is called an inversion if:

    i < j and nums[i] > nums[j]
    Return the number of permutations perm of [0, 1, 2, ..., n - 1] such that for all requirements[i], perm[0..endi] has exactly cnti inversions.

    Since the answer may be very large, return it modulo 10^9 + 7.

    Examples:
    >>> n = 3, requirements = [[2,2],[0,0]]
    2
    >>> n = 3, requirements = [[2,2],[1,1],[0,0]]
    1

    Constraints:
    2 <= n <= 300
    1 <= requirements.length <= n
    requirements[i] = [end_i, cnt_i]
    0 <= end_i <= n - 1
    0 <= cnt_i <= 400
    The input is generated such that there is at least one i such that end_i == n - 1.
    The input is generated such that all endi are unique
    """


Question:
Write a function to check a decimal with a precision of 2.
assert is_decimal('123.11')==True
assert is_decimal('e666.86')==False
assert is_decimal('3.124587')==False


Question:
Write a function to find three closest elements from three sorted arrays.
assert find_closet([1, 4, 10],[2, 15, 20],[10, 12],3,3,2) == (10, 15, 10)
assert find_closet([20, 24, 100],[2, 19, 22, 79, 800],[10, 12, 23, 24, 119],3,5,5) == (24, 22, 23)
assert find_closet([2, 5, 11],[3, 16, 21],[11, 13],3,3,2) == (11, 16, 11)


Question:
Write a python function to check whether the given number can be represented by sum of two squares or not.
assert sum_Square(25) == True
assert sum_Square(24) == False
assert sum_Square(17) == True


Question:
from typing import List

def filter_by_substring(strings: List[str], substring: str) -> List[str]:
    """ Filter an input list of strings only for ones that contain given substring
    >>> filter_by_substring([], 'a')
    []
    >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
    ['abc', 'bacd', 'array']
    """


Question:
def f(n):
    """ Implement the function f that takes n as a parameter,
    and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
    or the sum of numbers from 1 to i otherwise.
    i starts from 1.
    the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
    Example:
    f(5) == [1, 2, 6, 24, 15]
    """


Question:
def min_moves_to_capture_queen(a: int, b: int, c: int, d: int, e: int, f: int) -> int:
    """
    There is a 1-indexed 8 x 8 chessboard containing 3 pieces.

    You are given 6 integers a, b, c, d, e, and f where:

    (a, b) denotes the position of the white rook.
    (c, d) denotes the position of the white bishop.
    (e, f) denotes the position of the black queen.

    Given that you can only move the white pieces, return the minimum number of moves required to capture the black queen.

    Note that:

    Rooks can move any number of squares either vertically or horizontally, but cannot jump over other pieces.
    Bishops can move any number of squares diagonally, but cannot jump over other pieces.
    A rook or a bishop can capture the queen if it is located in a square that they can move to.
    The queen does not move.

    Examples:
    >>> a = 1, b = 1, c = 8, d = 8, e = 2, f = 3
    2
    >>> a = 5, b = 3, c = 3, d = 4, e = 5, f = 2
    1

    Constraints:
    1 <= a, b, c, d, e, f <= 8
    No two pieces are on the same square.
    """