{"id":8089,"date":"2021-09-30T16:00:13","date_gmt":"2021-09-30T10:30:13","guid":{"rendered":"https:\/\/python-programs.com\/?p=8089"},"modified":"2021-11-22T18:34:25","modified_gmt":"2021-11-22T13:04:25","slug":"python-program-to-find-the-missing-number-in-an-array-list","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-missing-number-in-an-array-list\/","title":{"rendered":"Python Program to Find the Missing Number in an array\/list"},"content":{"rendered":"

Our website provided core java programs examples with output<\/a> aid beginners and expert coders to test their knowledge gap and learn accordingly.<\/p>\n

Lists in Python:<\/strong><\/p>\n

Python contains a collection of built-in data types that make typical data-wrangling tasks simple. The list is one of them, a simple but useful collection type. A Python list allows you to collect Python objects in a one-dimensional row that may be accessed by position, added, removed, sorted, and subdivided.<\/p>\n

Find the missing number in an array\/list of n-1 different numbers in the range of 1 to n in linear time in Python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given list= [ 1 ,3 ,2 , 6 , 5 ]<\/pre>\n

Output:<\/strong><\/p>\n

The missing number in the given list 4<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given list= [ 1 , 9 , 2 ,3 , 5 , 4 , 6 , 7 ]<\/pre>\n

Output:<\/strong><\/p>\n

The missing number in the given list 8<\/pre>\n

Program to Find the Missing Number in an array\/list in Python<\/h2>\n

There are several to find the missing number in an array\/list in python but to do the same thing in linear time we use either mathematical formula or bit manipulation techniques like below.<\/p>\n