KEMBAR78
Strong Problem Statment | PDF | String (Computer Science) | Computer Programming
0% found this document useful (0 votes)
24 views3 pages

Strong Problem Statment

The document outlines 20 programming tasks related to string manipulation, including reversing strings, checking for palindromes, counting vowels and consonants, and more. Each task includes a question, logic for implementation, a sample input, and the expected output. The tasks are designed to enhance understanding of string operations and algorithms.

Uploaded by

Akash Satdeve
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Strong Problem Statment

The document outlines 20 programming tasks related to string manipulation, including reversing strings, checking for palindromes, counting vowels and consonants, and more. Each task includes a question, logic for implementation, a sample input, and the expected output. The tasks are designed to enhance understanding of string operations and algorithms.

Uploaded by

Akash Satdeve
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

String

1. Reverse a String:
○ Question: Write a program to reverse a given string.
○ Logic: Use a loop to reverse the characters in the string.
○ Sample Input: "hello"
○ Expected Output: "olleh"
2. Check for Palindrome:
○ Question: Write a program to check if a given string is a palindrome.
○ Logic: Use loops to compare characters from the start and end of the
string.
○ Sample Input: "racecar"
○ Expected Output: Palindrome
3. Count Vowels and Consonants:
○ Question: Write a program to count the number of vowels and
consonants in a given string.
○ Logic: Use loops and conditional statements to categorize characters.
○ Sample Input: "hello"
○ Expected Output: Vowels: 2, Consonants: 3
4. Check for Anagrams:
○ Question: Write a program to check if two strings are anagrams of
each other.
○ Logic: Check if the character counts in both strings are the same.
○ Sample Input: "listen" and "silent"
○ Expected Output: Anagrams
5. Check for Pangram:
○ Question: Write a program to check if a given string is a pangram
(contains all letters of the alphabet).
○ Logic: Use loops to check if all letters are present.
○ Sample Input: "The quick brown fox jumps over the lazy dog."
○ Expected Output: Pangram
6. Remove Duplicates from a String:
○ Question: Write a program to remove duplicate characters from a
string.
○ Logic: Use a hash set or loops to track unique characters.
○ Sample Input: "programming"
○ Expected Output: "progamin"
7. Count Substrings in a String:
○ Question: Write a program to count the number of occurrences of a
substring in a given string.
○ Logic: Use loops to search for the substring and count occurrences.
○ Sample Input: "abababab" and "ab"
○ Expected Output: 4
8. Check for Rotation:
○ Question: Write a program to check if one string is a rotation of
another string.
○ Logic: Concatenate one string with itself and check if the other string is
a substring.
○ Sample Input: "waterbottle" and "erbottlewat"
○ Expected Output: Rotation
9. Remove White Spaces:
○ Question: Write a program to remove white spaces from a string.
○ Logic: Use loops to remove spaces or use a regular expression.
○ Sample Input: "hello world"
○ Expected Output: "helloworld"
10. Count Words in a String:
○ Question: Write a program to count the number of words in a string.
○ Logic: Use loops to count spaces and words.
○ Sample Input: "This is a sentence."
○ Expected Output: 4
11. Reverse Words in a String:
○ Question: Write a program to reverse the order of words in a string.
○ Logic: Split the string into words, reverse the order, and join them back
together.
○ Sample Input: "Hello world"
○ Expected Output: "world Hello"
12. Title Case a Sentence:
○ Question: Write a program to convert the first letter of each word to
uppercase in a sentence.
○ Logic: Split the sentence into words and capitalize the first letter of
each word.
○ Sample Input: "this is a test"
○ Expected Output: "This Is A Test"
13. Check for Subsequence:
○ Question: Write a program to check if one string is a subsequence of
another.
○ Logic: Use loops to check if the characters of the subsequence are in
the same order.
○ Sample Input: "abc" and "ahbgdc"
○ Expected Output: Subsequence
14. Find Longest Common Prefix:
○ Question: Write a program to find the longest common prefix among
an array of strings.
○ Logic: Compare characters of all strings from left to right.
○ Sample Input: ["flower", "flour", "flight"]
○ Expected Output: "fl"
15. Compress a String:
○ Question: Write a program to compress a string by replacing
consecutive characters with their counts.
○ Logic: Use loops to count consecutive characters and create the
compressed string.
○ Sample Input: "aaabbbcccc"
○ Expected Output: "a3b3c4"
16. Reverse Each Word in a String:
○ Question: Write a program to reverse each word in a string.
○ Logic: Split the string into words, reverse each word, and join them
back together.
○ Sample Input: "Hello world"
○ Expected Output: "olleH dlrow"
17. Check for Valid Parentheses:
○ Question: Write a program to check if a string containing parentheses
is valid.
○ Logic: Use a stack to keep track of open and close parentheses.
○ Sample Input: "({[()]})"
○ Expected Output: Valid
18. Find the First Non-Repeating Character:
○ Question: Write a program to find the first non-repeating character in a
string.
○ Logic: Use loops to count characters and find the first non-repeating
character.
○ Sample Input: "leetcode"
○ Expected Output: "l"
19. Check for a Valid Palindromic String:
○ Question: Write a program to check if a given string is a valid
palindromic string after ignoring non-alphanumeric characters and
considering case.
○ Logic: Use loops to compare characters while ignoring non-
alphanumeric characters.
○ Sample Input: "A man, a plan, a canal: Panama"
○ Expected Output: Valid Palindrome
20. Count and Say Sequence:
○ Question: Write a program to generate the nth term of the "Count and
Say" sequence.
○ Logic: Use loops to generate the sequence based on the previous
term.
○ Sample Input: 4
○ Expected Output: "1211"

You might also like