CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int count[1000000]={0};
for(int j=0;j<n;j++)
{
for(int k=0;k<1000000;k++)
{
if(arr[j]==k)
{
count[k]++;
}
}
}
int maxi=count[0];
int ele=0;
for(int p=0;p<1000000-1;p++)
{
if(count[p+1]>maxi)
{
maxi=count[p+1];
ele=p+1;
}
}
cout<<ele<<" "<<maxi;


}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
bool checkf(int ai, int f)
{
	if(ai==f) return 1;
	else return 0;
}
bool checkr(int arr[], int n, int i)
{
	for(int j = 0; j < i; j++)
	{
	if (arr[i]==arr[j]) return 0;
	};
	return 1;
} 
int main()
{
	int n;
	cin >> n;
	int a[n]; int b[n];
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
	};
	for(int i = 0; i < n; i++)
	{
		a[i]=0;
	};
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(b[i]==b[j])
			{
				a[i]++;
			};
		};
	};
	int frequency = 0;
	for(int i = 0; i < n; i++)
	{
		frequency = max(a[i], frequency);
	};
	for(int i = 0; i < n; i++)
	{
		if (checkf(a[i], frequency) && checkr(b, n, i))
		{
			cout << b[i] << " " << frequency << '\n';
		};
		
	
	};
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include <iostream>
#include <cmath>

using namespace std;

int main(){
int n;
cin >> n;
int a[n],b[20];
for(int i=0;i<n;i++){cin >> a[i];}



for (int i=0;i<20;i++)b[i]=0;
for (int i=0;i<n;i++){
for (int t=0;t<n;t++){

if (a[t]==a[i])b[i]++;


    
 }   
}

int j=0;
for(int i=0;i<20;i++){
j=max(j,b[i]);
}
int index=0;
for(int i=0;i<20;i++){
if(j==b[i])index=i;
}
cout << a[index] << " " << j;
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int major( int *a, int *b, int *n){
int n=0;
for (int i=0; i<n && a[i]; i=-1; i++){
b[i]=1;
for(int j= j+1; j<n; j++){
if(a[i]==a[j]){
b[j]++;
a[j]=1;
}
}
}
}
for (int i=0; n=0;i<n; a[i] != -1){
if ( a[i] i=-1){
if (b[n]< b[j]){
b[n]=0;
n=i;
}
}
}

int main(){
int n;
n>=1; n<20;
cin>>n;
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include <iostream>
using namespace std;
int max(int *counter,int n){
	int argmax=0;
	for(int i=0;i<n;i++){
		if(counter[argmax]<counter[i]) argmax=i;	
	}
	return argmax;
}

int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){cin>>a[i];}
	int counter[n];
	for(int i=0;i<n;i++){
		int count=0;
		for (int j=0;j<n;j++){
			if (a[i]==a[j]) count++;
		}
		counter[i]=count;
	}
	cout<<a[max(counter,n)]<<" "<<counter[max(counter,n)];
	
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include <iostream>
using namespace std;

int occurence(int arr[], int n, int j){
	int count = 0;
	for(int i = 0; i<n; i++){
		if(arr[i]==j) count += 1;
	}
	return count;
}

int max_occurence(int arr[], int n, int& winner){
	int max = 0;
	for(int i = 0; i<n; i++){
		int val = occurence(arr, n, arr[i]);
		if(max < val) {
			max = val;
			winner = arr[i];
		}
	}
	return max;
}

int main(){
	int n, winner;
	cin >> n;
	int arr[n];
	for(int i = 0; i<n; i++){
		cin >> arr[i];
	}
	int max_count = max_occurence(arr, n, winner);
	cout << winner << " " << max_count << endl;
	
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
//Q2
#include<iostream>
using namespace std;
int main()
{
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int counter_array[n];
	for(int i=0; i<n;i++) { counter_array[i]=0;}

	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
			if(a[i]==a[j]) {counter_array[i]++;}
		}
	}
	int max_index = 0;
	for(int i=0;i<n;i++)
	{
		if(counter_array[i]>counter_array[max_index]) max_index = i;
	}

	cout<<a[max_index]<<" "<<counter_array[max_index];
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
#include<cmath>
using namespace std;

void input_array(int* a,int n){
    for(int i=0; i<n; i++){
        int b;
        cin>>b;
        a[i]=b;
    }
}

int maxin (int* a, int n){
    int maxm=0;
    for (int i=0; i<n; i++){
        if (a[i]>a[maxm]) maxm=i;
    }
    return maxm;

}

void print (int* a, int n){
    for(int i=0; i<n; i++) cout<<a[i]<<" ";
}


int main()
{
    int n;
    cin>>n;
    int a[n];
    input_array(a,n);
        int fr[10000];
        for(int i=0; i<10000; i++) fr[i]=0;
        for (int i=0; i<n; i++){
            fr[a[i]-1]++;
        }
int freq=fr[maxin(fr,10000)];
int value= maxin(fr,10000)+1;
cout<< value<<" "<< freq;
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){cin>>a[i];}
	int count =1,max=0,ans=-1;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]==a[j]){count++;}
		}
		if(count>max){max=count;ans=a[i];}
		count =1;
	}
	cout<<ans<<' '<<max;
	return 0;
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<simplecpp>



main_program{
int no;
cin>>no;
int arr[no], countarr[no];
int count;

for (int i =0; i<no;i++){
	cin>>arr[i];
}

int size=sizeof(arr)/4;
//cout<<size;

/* for (int i =0; i<no;i++){
	cout<<arr[i]<<", ";
} */

for (int i =0; i<size;i++){
	count=0;
	for (int j=0; j<size; j++){
		if (arr[i]==arr[j]){
			count+=1;
		}
	}
	countarr[i]=count;
}

/* for (int i =0; i<no;i++){
	cout<<countarr[i]<<" ";
}
cout<<endl;*/

int max=countarr[0];int find=arr[0];

for (int i =1; i<size;i++){
	if (max< countarr[i]){
		max=countarr[i];
		find=arr[i];
	}
}

cout<<find<<" "<<max;








}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int main(){
	int a[20],n;
	cin>>n;
	
	for(int i=0;i<n;i++){a[i]=0;
	
	for(int j=0;j<n;j++){
		
		cin>>a[j];
		
	}
	a[i]++;
						 cout<<a[i];
}
			
	
			
		}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int argmax (int z[], int x[], int y) {
int maxindex = 0;
for(int m =1; m<y;m++) {
   if(x[maxindex] < x[m]) { maxindex = m;}
}
cout << z[maxindex] << x[maxindex];
return 0; 
}
int main() {
int n; cin >> n;
int a[n];
for(int i=0; i<n;i++) {
cin >> a[i]; }
int hist[n];
for(int i = 0; i<n; i++) {  hist[i] = 0;}

for(int i=0;i<n;i++) {
  for(int j=0;j<n;j++) {
  if(a[i] ==a[j]) { hist[i]++;}
  }
  }
 argmax(a,hist,20);
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int main()
{
int n,i,j,ptr;
cin>>n;
int a[n];
int b[n];

for(i=0;i<n;i++)
{
cin>>a[i];
}

for(i=0;i<n;i++)
{
b[i]=0;
for(j=0;j<n;j++)
{if(a[i]==a[j])
{
b[i]=b[i]+1;
}}}

int max=0;

for(i=0;i<n;i++)
{
if(b[i]>=max)
{max=b[i];
}}

for(i=0;i<n;i++)
{
ptr=0;
if(i!=0){
if(b[i]==max)
{

for(j=0;j<i;j++){
if (a[i]==a[j]){ptr=1;}
}
if(ptr==0){cout<<a[i]<<" "<<b[i]<<endl;}
}}
else{if(b[i]==max){cout<<a[i]<<" "<<b[i]<<endl;}}
}

}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
#include<cmath>
using namespace std;

int main(){
int n;
cin>>n;
int arr[n];

for(int i=0;i<n;i=i+1) cin>>arr[i];

int count[n];      for(int a=0;a<n;a=a+1) count[a]=0;

for(int i=0;i<n;i=i+1)
        {for(int j=0;j<n;j=j+1)
              {if(arr[i]==arr[j]) count[i]=count[i]+1;}
        }

int maxi=0;

for(int i=0;i<n;i=i+1)
      {if(count[i]>count[maxi]) maxi=i;}

cout<<arr[maxi]<<" "<<count[maxi];

return 0;
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<simplecpp>
int mymax(int* b,int n){int max=0;
for(int i=0;i<n;i++){
	if(b[i]>b[max]) max=i;
  }return max;
}
main_program{
int n;cin>>n;int a[n];int b[n];
	for(int i=0;i<n;i++){ cin>>a[i];b[i]=0;}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(a[i]==a[j])b[i]=b[i]+1;
  }
  } int k=mymax(b,n);cout<<a[k]<<" "<<b[k];
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;

int main(){
  int n;
  cin>>n;
 int A[n];
 int B[n];
for(int i=0;i<n;i++){
   B[i]=0; 
   }
for(int i=0;i<n;i++){
    cin>>A[i];
    }
for(int i=0;i<n;i++){
   for(int j=i;j<n;j++){
        if(A[i]==A[j])
	{B[i]++;}
       }
      }
  int max=0;
  for(int i=0;i<n;i++){
      if(B[max]<=B[i])
      {max=i;}
}
    cout<<A[max]<<" "<<B[max];
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];}
int s=0;
for(int j=0;j<n;j++){
s=max(s,a[j]);
}

int b[s+1];
for(int i=0;i<=s;i++){
b[i]=0;}
for(int k=0;k<=s;k++){
for(int i=0;i<n;i++){
if(a[i]==k){b[k]=b[k]+1;}}}
int x=0;
for(int i=0;i<=s;i++){
x=max(x,b[i]);}
for(int y=0;y<=s;y++){
if(x==b[y]) cout<< y<<" "<< x;}

}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: C