Q#6: Multiply array values, return the remainder

Suppose you’re given an array of varying length containing multiple #s, and a number x. Using these inputs, write a short program in Python find the remainder of the array multiplication divided by x.

For example:

#Given the following
array = [5,2,4,1,5]
x = 6
#We would calculate output as such:
5*2*4*1*5 = 200 % 6 = 2

-Credit: erik@interviewqs.com


array = input()
mult = 1
x = len(array)
for i in array:
mult = mult*i
print(mult % x)




Data Science tutorial working through solutions to Data Science Interview Questions

Recommended from Medium

Which programming language should I learn first if I could start over?

Building a serverless chatbot with AWS Lex, Lambda and Amazon Aurora: Part 1.

C#, a Steep Learning Curve


Mocking a monorepo

Leetcode — 79. Word Search

A Bird’s Eye View of Databases

Creating Boss Enemy Part 2!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abish Pius

Abish Pius

Data Science Professional who teaches with unflashy, simple to understand python code.

More from Medium

Solutions of leetcode question 22: Generate Parentheses

Making your own Custom-Python-Executable

How To Prepare for a Python Developer Interview — Ustacky Blog

Introduction to LinkedList