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> { ...
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 Today, we're building on our knowledge of Arrays by adding another dimension. Check out the Tutorial tab for learning materials and an instructional video! Context Given a 2D Array , : 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of values with indices falling in this pattern in 's graphical representation: a b c d e f g There are hourglasses in , and an hourglass sum is the sum of an hourglass' values. Task Calculate the hourglass sum for every hourglass in , then print the maximum hourglass sum. Input Format There are lines of input, where each line contains space-separated integers describing 2D Array ; every value in will be in the inclusive range of to . Constraints Output Format ...
Comments
Post a Comment