Skip to content

Commit 5c90e58

Browse files
authored
Create readme.md
1 parent 223fe01 commit 5c90e58

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Majority_element/readme.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Given an array A of N elements. Find the majority element in the array. A majority element in an array A of size N is an element that appears more than N/2 times in the array.
2+
3+
4+
Example 1:
5+
6+
Input:
7+
N = 3
8+
A[] = {1,2,3}
9+
Output:
10+
-1
11+
Explanation:
12+
Since, each element in
13+
{1,2,3} appears only once so there
14+
is no majority element.
15+
Example 2:
16+
17+
Input:
18+
N = 5
19+
A[] = {3,1,3,3,2}
20+
Output:
21+
3
22+
Explanation:
23+
Since, 3 is present more
24+
than N/2 times, so it is
25+
the majority element.

0 commit comments

Comments
 (0)