Find n-th missing element in unsorted array

InterviewQs

Find n-th missing element in unsorted array

Python Data Structures Arrays

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

Suppose you're given an unsorted array, a. The array is intended to have all integer elements between its minimum and maximum, but could be missing some elements. Write a python function to find the n-th missing element in the array.

Consider the array in sorted order, then find the n-th missing number. If the n-th missing number does not exist, you can output 'Does not exist'.

Examples:

    

Input: a = [2, 3, 11, 9], n = 3

Output: 6

Missing elements in array: [4, 5, 6, 7, 8, 10]. So, the 3rd missing element is 6.


    

Input: a = [2, 3, 5], n = 5

Output: 'Does not exist'

Since there is no 5th missing element in the array, we output 'Does not exist' (the only missing element here is 4).



 

Congratulations! You’ve accumulated 162 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

Employee survey results

Friday, July 16, 2021

SQL, Database Querying, InterviewQs Employee survey results SQL Database Querying Forward this email to a friend or colleague and challenge them to solve it. You're consulting for a company, and

Consumer complaints on financial products

Monday, July 12, 2021

Data Analysis, Python, Pandas, Data Manipulation, External Dataset, InterviewQs Consumer complaints on financial products Data Analysis Python Pandas Data Manipulation External Dataset Forward this

Subarrays having a sum of p

Saturday, July 10, 2021

Python, Data Structures, Arrays, InterviewQs Subarrays having a sum of p Python Data Structures Arrays Forward this email to a friend or colleague and challenge them to solve it. Suppose you have an

Delivery times

Saturday, July 10, 2021

Data Analysis, Python, Pandas, T-test, InterviewQs Delivery times Data Analysis Python Pandas T-test Forward this email to a friend or colleague and challenge them to solve it. Suppose you are working

State populations

Monday, July 5, 2021

SQL, Database Querying, Window Function, InterviewQs State populations SQL Database Querying Window Function Forward this email to a friend or colleague and challenge them to solve it. Suppose you come

You Might Also Like

Hacker Newsletter #697

Friday, April 26, 2024

Don't watch the clock; do what it does. Keep going. //Sam Levenson hackernewsletter Issue #697 // 2024-04-26 // View in your browser #Favorites Lattice is the AI-powered people platform that

TikTok threatens shutdown 📱, FCC passes net neutrality 🌐, the robotics renaissance 🤖

Friday, April 26, 2024

ByteDance would rather shut down TikTok than sell the company Sign Up |Advertise|View Online TLDR Together With Plaid TLDR 2024-04-26 6 fintech predictions you need to know for 2024 (Sponsor)

📧 What's inside MMA and how it can help you

Friday, April 26, 2024

What's Inside Modular Monolith Architecture? Hey there! 👋 I wish you an excellent end to the week. What better way to spend the weekend than diving headfirst into a 12+ hour course? Well, maybe

Data Science Weekly - Issue 544

Friday, April 26, 2024

Curated news, articles and jobs related to Data Science, AI, & Machine Learning ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Develop highly relevant search applications using AI

Friday, April 26, 2024

New Elasticsearch and AI training ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ elastic | Search. Observe. Protect A world of AI possibilities door-test 2.png Explore

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