In this exercise you will practice using arrays & strings to solve coding problems, and then identify the time and space complexity of your solution. Try to write solutions with minimal time and space complexity.
Do not use the following methods:
reverse
reverse!
- Use loops, strings and arrays to solve coding problems
- Identify the time & space complexity of a given method
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
Note: For the purpose of this problem, we define empty string as valid palindrome.
Input: "A man, a plan, a canal: Panama"
Output: true
Input: "race a car"
Output: false
Write longest_prefix(strings)
to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string "".
Input: ["flower","flow","flight"]
Output: "fl"
Example 2:
Input: ["dog","racecar","car"]
Output: ""
Explanation: There is no common prefix among the input strings.
All given inputs are in lowercase letters a-z.
Taken from leetcode.com: