Objective Today, we're learning about Key-Value pair mappings using a Map or Dictionary data structure. Task Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each queried, print the associated entry from your phone book on a new line in the form name=phoneNumber ; if an entry for is not found, print Not found instead. Note: Your phone book should be a Dictionary/Map/HashMap data structure. Input Format The first line contains an integer, , denoting the number of entries in the phone book. Each of the subsequent lines describes an entry in the form of space-separated values on a single line. The first value is a friend's name, and the second value is an -digit phone number. After the lin...
Objective Welcome to the last day! Today, we're discussing bitwise operations. Task Given set . Find two integers, and (where ), from set such that the value of is the maximum possible and also less than a given integer, . In this case, represents the bitwise AND operator. Input Format The first line contains an integer, , the number of test cases. Each of the subsequent lines defines a test case as space-separated integers, and , respectively. Constraints Output Format For each test case, print the maximum possible value of on a new line. Sample Input 3 5 2 8 5 2 2 Sample Output 1 4 0 Explanation All possible values of and are: The maximum possible value of that is also is , so we p...
Objective Today we're discussing Generics; be aware that not all languages support this construct , so fewer languages are enabled for this challenge. Task Write a single generic function named printArray ; this function must take an array of generic elements as a parameter (the exception to this is C++, which takes a vector ). The locked Solution class in your editor tests your function. Note: You must use generics to solve this challenge. Do not write overloaded functions. Input Format The locked Solution class in your editor will pass different types of arrays to your printArray function. Constraints You must have exactly function named printArray . Output Format Your printArray function should print each element of its generic array parameter on a new line. Solution : import java.util.*; class Printer <T> { ...
Comments
Post a Comment