Category Uncategorized

Python exercise 23: Two sum

Question Given an array of integers nums and an integer target, return _indices of the two numbers such that they add up to MARKDOWN_HASH42aefbae01d2dfd981f7da7d823d689eMARKDOWNHASH. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer…

Python exercise 22: ransomnote

Question Given two strings ransomNote and magazine, return true if ransomNote_can be constructed by using the letters from_ magazine and false otherwise. Each letter in magazine can only be used once in ransomNote. Example Example 1: Input: ransomNote = "a", magazine = "b" Output: false Example 2: Input: ransomNote = "aa", magazine…

Python Exercise 20:Find the pattern

Question Given a dictionary containing up to six phrases, return a list containing the matching phrases according to the given string (p). Ignore any digit that is placed after or before the given string. Whether the first letter is capitalized or…

Python exercise 18:Sales Season

Question A retailer is having a store-wide "buy 2, get 1 free" sale. For legal reasons, they can’t charge their customers $0 for an article so a discount is applied to all products instead. — Create a function that takes…

Python exercise 17: convert number to english word

Question Write a function that accepts a positive integer between 0 and 999 inclusive and returns a string representation of that integer written in English. Example num_to_eng(0) ➞ "zero" num_to_eng(18) ➞ "eighteen" num_to_eng(126) ➞ "one hundred twenty six" num_to_eng(909) ➞ "nine hundred nine" My…