Ac 1
Ac 1
A.Prathiba
VU21CSEN0101484
1)Remove an element: Given an integer array arr and an integer key, write a program in C to
return the number of values not equal to key.
2) Remove duplicates from a given array: Given a sorted integer array arr, write a program in C
to return the array after removing the duplicates, with all the other elements in place.
3) Best time to sell a commodity: Given an array of positive integers that represent the price of a
commodity on a given day, return two integers which represent the best day to buy and later,
sell the commodity.
4)String reversal: Given an string with words separated by empty spaces, commas or fullstops,
write a program to return the string after removing the commas and fullstops and reversing the
words in the string.
5) Move all zeros to the end: Given an integer array arr, return the array with all the zeros
moved to the end of the array. The relative ordering of the non-zero lements should not change.
6) Is substring: Given two strings str1 and str2, write a program to return true if str2 is a
substring of str1 and false otherwise.
8) Is subsequence: Given two strings str1 and str2, write a program to return true if str2 is a
subsequence of str1 and false otherwise.
9) Maximum value subarray: Given an array of integers arr, return the maximum sum of a
subarray (with contiguous elements) of that array.
10) Single occurence of a number: Given an array of integers which all numbers but one
occuring twice, find the number that occurs only once.