Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

July 2023 CSE 282

Offline: Character and String


Subsections A1 & A2
Deadline
January 19, 2024 11.55 PM

Submission Guidelines
Make a C file for the problem. The name of the file should be like 2118xyz_Problem1.c. Make a
folder named “2118xyz” where should put only the C file (Not the .exe or other files). Now zip
the folder. Finally upload the zip file to the submission link of the moodle within the deadline.
[Note that, you should replace xyz with the last three digits of your student id]. For example, for
ID 2118001 the submitted file would be: 2118001.zip
After extracting, there should be a folder named 2118001 and a file named 2118001_Problem1.c
inside it.

Problem
Write a C function remove_duplicates that takes a string as input and removes duplicate
characters, keeping only the first occurrence of each character. The function should modify the
original string.
Input
A string str of length L (1 <= L <= 1000) containing only lowercase English letters (a-z).

Output
The function should modify the original string str to remove duplicate characters, keeping only
the first occurrence of each character.

Test Case
Input Output

programming progamin

hello helo

Explanation
In the first test case, the string "programming" has duplicates 'r' and 'g'. The function removes the
duplicates, and the modified string is "progamin".

In the second test case, the string "hello" has a duplicate 'l'. The function removes the duplicate,
and the modified string is "helo".

You might also like