Same Element Count

For Complete YouTube Video: Click Here

In this class, we will understand the Same Element Count.

The entire course of C Programming with more than 110+ videos of content or playlist has already been published.

We have covered all the concepts of C Programming in a very detailed way.

C Programming Complete Playlist on YouTube: Click Here

All the concepts discussed in this course are the models frequently asked in Campus Placements Questions, either in multiple-choice questions or as programming questions.

This entire course will help a Computer Science Engineering Student or a student in any other stream crack the campus placements drives held by Service-based Software or IT companies like TCS, Infosys, CTS, Wipro, Accenture, etc.

Table of Contents

Same Element Count

Question

Count occurrences of the same even numbers that appear adjacently.

Example:

Input: 8, [1,2,2,2,5,5,4,4]

Output: 3

Given Code:

int sameElementCount(int size, int *inputList)
{
	int i, count =0;
	for(i=0;i<size-1;i++)
	{
		if((inputList[i]%2 == 0) && (intputList[i] == inputList[i++]))
			count++;
	}
	return count;
}   

In the above code, there are some mistakes in the problem.

The explanation of the question is provided in the above YouTube link.