MAJORITY ELEMENT

Правка en2, от Unknown_712, 2021-03-08 09:12:12

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.

Input: N = 3 A[] = {1,2,3} Output: -1 Explanation: Since, each element in {1,2,3} appears only once so there is no majority element.

IF ANY MAJORITY FOUND IN THE ARRAY PRINT IT OTHERWISE PRINT -1.

CAN ANY SOLVE THIS QUESTION IN - TIME COMPLEXICTY O(N) SPACE COMPLEXICITY O(1)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Unknown_712 2021-03-08 09:12:12 168
en1 Английский Unknown_712 2021-03-08 09:10:13 566 A BEAUTIFUL PROBLEM OF MAJORITY ELEMENT (published)