ghostfruitleaf / array-string-practice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array & String Practice

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!

Learning Goals

  • Use loops, strings and arrays to solve coding problems
  • Identify the time & space complexity of a given method

Wave 1 - Valid Palindrome

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.

Palindrome Example 1

Input: "A man, a plan, a canal: Panama"
Output: true

Palindrome Example 2

Input: "race a car"
Output: false

Wave 2 - Longest Prefix

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 "".

Longest Prefix Example 1

Input: ["flower","flow","flight"]
Output: "fl"
Example 2:

Longest Prefix 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.

Source

Taken from leetcode.com:

About


Languages

Language:Ruby 93.4%Language:Dockerfile 6.3%Language:Shell 0.2%