We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All about Between Two Sets
The text was updated successfully, but these errors were encountered:
import java.io._ import java.math._ import java.security._ import java.text._ import java.util._ import java.util.concurrent._ import java.util.function._ import java.util.regex._ import java.util.stream._ import scala.collection.immutable._ import scala.collection.mutable._ import scala.collection.concurrent._ //import scala.collection.parallel.immutable._ //import scala.collection.parallel.mutable._ import scala.concurrent._ import scala.io._ import scala.math._ import scala.sys._ import scala.util.matching._ import scala.reflect._ object Result { /* * Complete the 'getTotalX' function below. * * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER_ARRAY a * 2. INTEGER_ARRAY b */ def getTotalX(a: Array[Int], b: Array[Int]): Int = { // Write your code here (for(n <- a.max to b.min) yield { ( (for(e <- a) yield { n%e match { case 0 => 1 case _ => 0 } }).product * (for(e <- b) yield { e%n match { case 0 => 1 case _ => 0 } }).product ) }).sum } } object Solution { def main(args: Array[String]) { val printWriter = new PrintWriter(sys.env("OUTPUT_PATH")) val firstMultipleInput = StdIn.readLine.replaceAll("\\s+$", "").split(" ") val n = firstMultipleInput(0).toInt val m = firstMultipleInput(1).toInt val arr = StdIn.readLine.replaceAll("\\s+$", "").split(" ").map(_.trim.toInt) val brr = StdIn.readLine.replaceAll("\\s+$", "").split(" ").map(_.trim.toInt) val total = Result.getTotalX(arr, brr) printWriter.println(total) printWriter.close() } }
Sorry, something went wrong.
NicolaBernini
No branches or pull requests
Overview
All about Between Two Sets
The text was updated successfully, but these errors were encountered: