Homework 1
Given an array of size n, find the majority element. The majority element is the element that appears more than floor( n/2 ) times. You may assume that the array is non-empty and the majority element always exist in the array.
The name of the submission should be homework1.cpp, no numbers, no name, no capital letters.
All homeworks must have the following at the top of the submitted file
- File name: homework1.cpp
- Created by:
- Created on:
- Synopsis:
int majorityElement(vector<int>& nums) {
// Write your solution here.
}
Here is the file, you just have to fill in the function. hw_1
CSE 2122 material is licensed under a Creative
Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Source code for this website available at GitHub.