Question: Find two indexes from a list whose values are summed up to a predefined target number. Input: A list of integers and a target number. Output: another list containing two (or a pair of) indexes of the input list whose values summed up to the target number. If such pair does not exist, return … Read more
Question: A straightforward way to find a median from a list of numbers would be to first sort the list and then pick the middle element. Using this approach, the time complexity would be dominated by the sorting algorithm, which is O(n log n). Now, your task is to find a median in a linear … Read more
Question: Create a function to print a diamond with the pattern shown in the example below. The function has one input, n, an integer that controls the size of the diamond. Answer: The key here is to first separate the printing of the top and bottom half. Then, for each half, find the pattern of … Read more
Question: Create a function to print a rectangle with the pattern shown below. The size of the rectangle is the input to the function. Answer: The key here is to separate the printing of the first and last row from the middle rows. 👍 Have fun while coding with Python! 👌 Please Subscribe to receive notifications on … Read more
Question: An isosceles triangle is a triangle with two sides of equal length. Given an input, print an isosceles triangle according to the examples below. You would have to find the pattern. Answer: The key here is finding the right number of spaces and asterisks (*) to print in each row. Then we can use … Read more
Question Print a right triangle with the size specified in the input. See the example below: Answer 👍 Have fun while coding with Python! 👌 Please Subscribe to receive notifications on future challenges. 💬 If you have any questions simply write a comment down below.