Skip to content

Instantly share code, notes, and snippets.

@asadali3210
Created May 31, 2017 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asadali3210/2891f050ac8a509ea7e316bfdbd74656 to your computer and use it in GitHub Desktop.
Save asadali3210/2891f050ac8a509ea7e316bfdbd74656 to your computer and use it in GitHub Desktop.
Given an array of characters, write a function that finds the maximum sequence of characters at the end of this array that are the same as the beginning of the array.
Input: Array of Characters
Output: Array of Characters
Examples:
Input = [a,b,c,e,r,t,x,s,b,a,b,c]
Output = [a,b,c]
(because a,b,c are both at the beginning and end of the array and is the maximum sequence of such characters)
Input = [q,e,r,l,q,e,r,l]
Output = [q,e,r,l]
Input = [r,j,k,e,r,s,b,a,b,c]
Output = []
(empty array, because no sequence of same characters exists at the beginning and end of the array)
Instructions:
- You can choose any programming language.
- Don't use any built-in functions in any language. Just write your own algorithm and functions as needed.
- Don’t do search on Google for the answers. Please do the answer based on your best knowledge.
- Please do all of your answers in the provided answer field. Use of any other text editor is not allowed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment