Problem:- Consider an array of integers, , where every element in occurs exactly twice except for one unique element.Find and print the unique element.
Input :- 4 9 95 93 57 4 57 93 9 #Input array with 95 as unique element.
Output:- 95
Background of XOR operator ( ^ ) :- Bit-wise operator which results zero, if XOR operator is applied between same bits otherwise gives 1.
We can use XOR operation to reset all bit for two numbers , if they are same. i.e : 3 ^ 3 = 0
Sample output:-
>>>
Enter size of array (Input)
9
Enter elements separated by space
4 9 95 93 57 4 57 93 9
Unique element is
95
Input :- 4 9 95 93 57 4 57 93 9 #Input array with 95 as unique element.
Output:- 95
Background of XOR operator ( ^ ) :- Bit-wise operator which results zero, if XOR operator is applied between same bits otherwise gives 1.
XOR Operator operation |
Sample program to print unique element using XOR :-
#!/bin/python def lonely_integer(a): storage = a[0] for i in range(1, a.__len__()): storage = storage ^ a[i] #print (storage) return storage print "Enter size of array (Input) " n = int(raw_input().strip()) print "Enter elements separated by space " a = map(int,raw_input().strip().split(' ')) print "Unique element is " print lonely_integer(a)
Sample output:-
>>>
Enter size of array (Input)
9
Enter elements separated by space
4 9 95 93 57 4 57 93 9
Unique element is
95
Thanks for the informative article. This is one of the best resources I have found in quite some time.
ReplyDeleteHadoop Admin Training in Chennai
Hadoop Administration Course in Chennai
TOEFL Coaching in Chennai
French Classes in Chennai
pearson vue test center in chennai
Informatica Training in Chennai
spanish language in chennai
content writing training in chennai
Hadoop Admin Training in Adyar
Hadoop Admin Training in Velachery
The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. machine learning projects for final year In case you will succeed, you have to begin building machine learning projects in the near future.
DeleteProjects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.
Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.
The Nodejs Projects Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
iso 27001 certification services
ReplyDeleteiso 27001 certification in delhi
ISO 9001 Certification in Noida
iso 22000 certification in Delhi
iso certification in noida
ReplyDeleteiso certification in delhi
ce certification in delhi
iso 14001 certification in delhi
iso 22000 certification cost
iso consultants in noida
we have provide the best fridge repair service.
ReplyDeleteWashing Machine Repair In Faridabad
LG Washing Machine Repair In Faridabad
Videocon Washing Machine Service Centre In Faridabad
IFB Washing Machine service centre in faridabad
Samsung Washing Machine Repair In Faridabad
Washing Machine Repair in Noida
godrej washing machine repair in noida
whirlpool Washing Machine Repair in Noida
IFB washing Machine Repair in Noida
LG Washing Machine Repair in Noida
we have provide the best ppc service.
ReplyDeleteppc company in gurgaon
website designing company in Gurgaon
PPC company in Noida
seo company in gurgaon
PPC company in Mumbai
PPC company in Chandigarh
Digital Marketing Company
Rice Bags Manufacturers
ReplyDeletePouch Manufacturers
fertilizer bag manufacturers
Lyrics with music
Great Article. Thank you for sharing! Really an awesome post for every one.
ReplyDeleteIEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.
Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai
Aivivu đại lý vé máy bay, tham khảo
ReplyDeleteve may bay di my gia re
đặt vé máy bay đà lạt hà nội
vé máy bay hà nội đến sài gòn
vé máy bay đi nha trang pacific airlines
vé từ mỹ về việt nam
thuê xe đi sân bay nội bài giá rẻ
Combo Quy Nhơn