From 7094514847d3e590ce7de175c6c4716de2c7549c Mon Sep 17 00:00:00 2001 From: hridyanshuk Date: Tue, 12 Oct 2021 17:34:58 +0530 Subject: [PATCH] Answer 15 --- Answer15.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Answer15.cpp diff --git a/Answer15.cpp b/Answer15.cpp new file mode 100644 index 0000000..8e782dc --- /dev/null +++ b/Answer15.cpp @@ -0,0 +1,44 @@ +#include + +using namespace std; + +int main() +{ + /* + Input Format: + First line: Number of elements in array + Second line: Elements of the array + eg: + 7 + 1 2 3 3 3 1 3 + + Output Format: + Majority Element (if it exists) + "Does not exist" if majority element does not exist + */ + int n; + cin>>n; + int arr[n]; + for(int i=0 ; i>arr[i]; + } + int count[n]={0}; + for(int i=0 ; i=(n/2+1)) + { + cout<