Skip to content

CGreenP/NPTEL-Introduction-to-Programming-in-C-Assignment-2-Question-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

NPTEL-Introduction-to-Programming-in-C-Assignment-2-Question-2

NPTEL Introduction to Programming in C Assignment 2 Question 2

Question 2

You are given a sorted (either in the increasing or in the decreasing order) sequence of numbers, ending with a -1. You can assume that are at least two numbers before the ending -1.

Let us call the sequence x0 x1 ... xn -1.

You have to output the number of distinct elements in the sorted sequence.

Kindly do not use arrays in the code.

Sample input 1

5 4 4 3 -1

Sample output 1

3

Sample input 2

1 2 -1

Sample output 2

2

Sample input 3

12 33  87 87 87 87 87  94 112 120 -1

Sample output 3

6

Sample input 4

1 2 2 -1

Sample output 4

2

Releases

No releases published

Packages

 
 
 

Languages