mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Add brute force solution
This commit is contained in:
parent
b4806f0903
commit
8bafd5c74a
1 changed files with 13 additions and 2 deletions
|
@ -14,11 +14,22 @@
|
|||
# @return {String}
|
||||
|
||||
#
|
||||
# Approach 1:
|
||||
# Approach 1: Brute Force
|
||||
#
|
||||
# Time Complexity:
|
||||
# Time Complexity: O(n)
|
||||
#
|
||||
def remove_vowels(s)
|
||||
result_array = []
|
||||
s.downcase
|
||||
start_array = s.split('')
|
||||
|
||||
start_array.each do |letter|
|
||||
if letter != 'a' && letter != 'e' && letter != 'i' && letter != 'o' && letter != 'u'
|
||||
result_array.push(letter)
|
||||
end
|
||||
end
|
||||
|
||||
result_array.join('')
|
||||
end
|
||||
|
||||
s = 'leetcodeisacommunityforcoders'
|
||||
|
|
Loading…
Reference in a new issue