Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5765 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4993 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1282 |

@bt8816103042 | 739 |

@rohitanand | 495 |

@codeantik | 479 |

@shalinibhataniya1097 | 472 |

@amrutakashikar2 | 464 |

@thealchemist627 | 456 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@dalwainazism125 | 453 |

@SherlockHolmes3 | 447 |

Complete Leaderboard |

Given an array **Arr** of size ** N**, the array contains numbers in range from

**Example 1:**

**Input:
**N = 4, K = 3
Arr[] = {2, 2, 1, 2}
**Output: **2
**Explanation:** 2 is the most frequent
element.

**Example 2:**

**Input:
**N = 6, K = 3
Arr[] = {2, 2, 1, 0, 0, 1}
**Output:** 0
**Explanation:** 0, 1 and 2 all have same
frequency of 2.But since 0 is smallest,
you need to return 0.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **maxRepeating()** which takes the array of integers **arr,** **n** and **k **as parameters and returns an integer denoting the answer.

**Expected Time Complexity:** O(N)

**Expected Auxiliary Space:** O(K)

**Constraints:**

1 <= N <= 10^{7}

1 <= K <= N

0 <= Arr_{i} <= K - 1

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Maximum repeating number

...