Data Interview Qs - Package colors

InterviewQs

Package colors

Python Algorithms Data Structures Arrays

Forward this email to a friend or colleague and challenge them to solve it.

Hi, 

Suppose there are packages that come in three colors: red, green, and blue. When two packages of differing colors are set next to each other, it's possible to trade them in for a package of the third remaining color.

Given N packages, determine the smallest number of packages remaining after any possible sequence of such transformations.

For example, given the input ['R', 'G', 'B', 'G', 'B'], it is possible to end up with a single package through the following steps:

    
Arrangement | Change
----------------------------------------
['R', 'G', 'B', 'G', 'B'] | (R, G) -> B
['B', 'B', 'G', 'B'] | (B, G) -> R
['B', 'R', 'B'] | (R, B) -> G
['B', 'G'] | (B, G) -> R
['R'] |

Solution will be written in Python for premium users.




 

You’ve accumulated 327 questions since joining our email list. Create a premium account to access detailed solutions to each problem (including this one) + our new Case studies.


Was this email forwarded to you? You can join our list here to receive questions

How did you like today's question?

15411 Boischatel, Montreal, QC, H9H1Y7, Canada
Don't want to get these emails anymore? We'll forgive you if you unsubscribe

Older messages

Assigned flight seating

Monday, August 1, 2022

Probability Theory, Probability Reasoning, InterviewQs Assigned flight seating Probability Theory Probability Reasoning Forward this email to a friend or colleague and challenge them to solve it. Hi,

Cumulative cash flows

Friday, July 29, 2022

SQL, Database Querying, Window Function, Cumulative Sum, InterviewQs Cumulative cash flows SQL Database Querying Window Function Cumulative Sum Forward this email to a friend or colleague and challenge

Modeling an epidemic

Wednesday, July 27, 2022

Python, Differential equations, Modeling, Stochastic Processes, InterviewQs Modeling an epidemic Python Differential equations Modeling Stochastic Processes Forward this email to a friend or colleague

Number of characters to create a palindrome

Monday, July 25, 2022

Python, Recursion, Python Functions, Algorithms, InterviewQs Number of characters to create a palindrome Python Recursion Python Functions Algorithms Forward this email to a friend or colleague and

Stationary distribution of AMZN stock

Friday, July 22, 2022

Python, Data Analysis, Pandas, Markov Chain, Stochastic Processes, Modeling, InterviewQs Stationary distribution of AMZN stock Python Data Analysis Pandas Markov Chain Stochastic Processes Modeling

You Might Also Like

Stripe makes more changes

Thursday, April 25, 2024

TikTok is in trouble, and net neutrality is back View this email online in your browser By Christine Hall Thursday, April 25, 2024 Welcome back to TechCrunch PM, your home for all things startups,

💎 Issue 414 - From a Lorry Driver to Ruby on Rails Developer at 38

Thursday, April 25, 2024

This week's Awesome Ruby Newsletter Read this email on the Web The Awesome Ruby Newsletter Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular Ruby news, articles and

💻 Issue 414 - JavaScript Features That Most Developers Don’t Know

Thursday, April 25, 2024

This week's Awesome Node.js Weekly Read this email on the Web The Awesome Node.js Weekly Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular Node.js news, articles and

💻 Issue 407 - The Performance Impact of C++'s `final` Keyword

Thursday, April 25, 2024

This week's Awesome .NET Weekly Read this email on the Web The Awesome .NET Weekly Issue » 407 Release Date Apr 25, 2024 Your weekly report of the most popular .NET news, articles and projects

💻 Issue 414 - Everyone Has JavaScript, Right?

Thursday, April 25, 2024

This week's Awesome JavaScript Weekly Read this email on the Web The Awesome JavaScript Weekly Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular JavaScript news, articles

📱 Issue 408 - All web browsers on iOS are just Safari with different design

Thursday, April 25, 2024

This week's Awesome iOS Weekly Read this email on the Web The Awesome iOS Weekly Issue » 408 Release Date Apr 25, 2024 Your weekly report of the most popular iOS news, articles and projects Popular

💧 Don't Bother Liquid Cooling Your AMD CPU — Why You Should Keep Using Live Photos on iPhone

Thursday, April 25, 2024

Also: We review the Unistellar Odyssey iPhone Telescope, and More! How-To Geek Logo April 25, 2024 Did You Know Charles Darwin and Abraham Lincoln were both born on the same day: February 12, 1809. 💻

💻 Issue 332 - 🥇The first framework that lets you visualize your React/NodeJS app 🤯

Thursday, April 25, 2024

This week's Awesome React Weekly Read this email on the Web The Awesome React Weekly Issue » 332 Release Date Apr 25, 2024 Your weekly report of the most popular React news, articles and projects

💻 Issue 409 - Sized, DynSized, and Unsized by Niko Matsakis

Thursday, April 25, 2024

This week's Awesome Rust Weekly Read this email on the Web The Awesome Rust Weekly Issue » 409 Release Date Apr 25, 2024 Your weekly report of the most popular Rust news, articles and projects

📱 Issue 411 - AI Starts to Sift Through String Theory's Near-Endless Possibilities

Thursday, April 25, 2024

This week's Awesome Swift Weekly Read this email on the Web The Awesome Swift Weekly Issue » 411 Release Date Apr 25, 2024 Your weekly report of the most popular Swift news, articles and projects