Given a string str and a corner string cs, we need to find out whether the string str starts and ends with the corner string cs or not.
Input : str = "geeksmanishgeeks", cs = "geeks" Output : Yes Input : str = "shreya dhatwalia", cs = "abc" Output : No
- Find length of given string str as well as corner string cs. Let this length be n and cl respectively.
- If cl>n, return false as cs can’t be greater than str.
- Otherwise, find the prefix and suffix of length cl from str. If both prefix and suffix match with corner string cs, return true otherwise return false.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Maximum length palindromic substring such that it starts and ends with given char
- Longest subsequence possible that starts and ends with 1 and filled with 0 in the middle
- Count substrings that starts with character X and ends with character Y
- Number of strings which starts and ends with same character after rotations
- Longest substring that starts with X and ends with Y
- Build a DFA to accept Binary strings that starts or ends with "01"
- Check if a number starts with another number or not
- Check if a number ends with another number or not
- Check whether the binary equivalent of a number ends with given string or not
- Ways to split string such that each partition starts with distinct character
- Program to build DFA that starts and end with 'a' from input (a, b)
- Program to build a DFA that checks if a string ends with "01" or "10"
- Find the smallest window in a string containing all characters of another string
- Find length of longest subsequence of one string which is substring of another string
- Count occurrences of a string that can be constructed from another given string
- Minimum number of given operations required to convert a string to another string
- Check if the given string is shuffled substring of another string
- C program to find and replace a word in a File by another given word
- Convert a given temperature to another system based on given boiling and freezing points
- Check if a string can be converted to another string by replacing vowels and consonants
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.