Twitter | Coding Round | Array Game

Result
Ongoing
Posted
28 Sept 2021
249 reads

Summary

I had a coding round with Twitter where I was given an array manipulation problem. I successfully implemented a solution for the 'Minimum Moves to Equal Array Elements' problem.

How it went

I recently interviewed with Twitter for a coding position. The interview consisted of a coding round where I was presented with a problem involving an array of integers. The task was to find the minimum number of operations to make all elements of the array equal, where an operation involved incrementing n-1 elements by one. I approached the problem by first understanding that incrementing n-1 elements is mathematically equivalent to decrementing one element relative to the others. Thus, the problem effectively reduces to making all elements equal to the minimum element in the array by only decrementing. My solution involved sorting the array in descending order and then iterating through it to sum the necessary moves.

Questions asked (1)

  1. 01

    Minimum Moves to Equal Array Elements

    Data Structures & Algorithms · Medium

    Given an integer array numbers of size n, you can perform an operation where you increment n-1 elements by 1. Find the minimum number of operations required to make all elements of the array equal.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Twitter recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!