{"id":8096,"date":"2021-09-30T16:00:38","date_gmt":"2021-09-30T10:30:38","guid":{"rendered":"https:\/\/python-programs.com\/?p=8096"},"modified":"2021-11-22T18:34:25","modified_gmt":"2021-11-22T13:04:25","slug":"python-program-to-find-the-odd-occurring-element-in-an-array-list","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-odd-occurring-element-in-an-array-list\/","title":{"rendered":"Python Program to Find the Odd Occurring Element in an Array\/list"},"content":{"rendered":"

Are you new to the java programming language? We recommend you to ace up your practice session with these Basic Java Programs Examples<\/a><\/p>\n

Given a list which contains all duplicate elements (each element occurs even times) except one element we have to find the odd occurring element.<\/p>\n

Given a array\/list the task is to print the odd occurring element in the given list.<\/p>\n

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

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

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

given list = [\u00a0 3 , 5, 4 ,1 ,4 ,8 ,5 , 1 ,3]<\/pre>\n

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

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

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

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

given list = [ 1 , 4 ,2 ,4 ,1]<\/pre>\n

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

The odd occurring number in the given list 2<\/pre>\n

Program to Find the Odd Occurring Element in an Array\/list in Python<\/h2>\n

There are several ways to find the odd occurring element in an array .<\/p>\n

The first thought is to run two loops and use the count to determine the frequency of the items.<\/p>\n

If the count is one, the element is the odd one out in the specified array\/list.<\/p>\n

But this approach takes two loops. This approach therefore requires O(n^2) time complexity.<\/p>\n

This program is therefore not an efficient way.<\/p>\n

We will look at the efficient approaches below.<\/p>\n