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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Build a DFA to accept Binary strings that starts or ends with "01"
- Longest subsequence possible that starts and ends with 1 and filled with 0 in the middle
- Number of strings which starts and ends with same character after rotations
- Maximum length palindromic substring such that it starts and ends with given char
- Ways to split string such that each partition starts with distinct character
- Program to build a DFA that checks if a string ends with "01" or "10"
- Check whether the binary equivalent of a number ends with given string or not
- Count substrings that starts with character X and ends with character Y
- String Range Queries to find the number of subsets equal to a given String
- Find the longest sub-string which is prefix, suffix and also present inside the string
- Find the longest sub-string which is prefix, suffix and also present inside the string | Set 2
- Given a string and an integer k, find the kth sub-string when all the sub-strings are sorted according to the given condition
- Find length of longest subsequence of one string which is substring of another string
- Find the character in first string that is present at minimum index in second string
- Find the count of palindromic sub-string of a string in its sorted form
- Queries to find the last non-repeating character in the sub-string of a given string
- Find the smallest window in a string containing all characters of another string
- Find Kth largest string from the permutations of the string with two characters
- Queries to find the first non-repeating character in the sub-string of a string
- Find a palindromic string B such that given String A is a subsequense of B
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.