mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Add remove vowels challenge
This commit is contained in:
parent
c4725e9eb2
commit
b4806f0903
2 changed files with 30 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
* [Get Products Of All Other Elements](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/arrays/get_products_of_all_other_elements.rb)
|
||||
* [Jewels And Stones](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/arrays/jewels_and_stones.rb)
|
||||
* [Remove Elements](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/arrays/remove_elements.rb)
|
||||
* [Remove Vowels](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/arrays/remove_vowels.rb)
|
||||
* [Single Number](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/arrays/single_number.rb)
|
||||
* [Sort Squares Of An Array](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/arrays/sort_squares_of_an_array.rb)
|
||||
* [Two Sum](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/arrays/two_sum.rb)
|
||||
|
|
29
data_structures/arrays/remove_vowels.rb
Normal file
29
data_structures/arrays/remove_vowels.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Challenge name: Remove vowels from a string
|
||||
#
|
||||
# Given a string s, remove the vowels 'a', 'e', 'i', 'o', and 'u'
|
||||
# from it, and return the new string.
|
||||
# Example 1:
|
||||
# Input: s = "leetcodeisacommunityforcoders"
|
||||
# Output: "ltcdscmmntyfrcdrs"
|
||||
#
|
||||
# Example 2:
|
||||
# Input: s = "aeiou"
|
||||
# Output: ""
|
||||
#
|
||||
# @param {String} s
|
||||
# @return {String}
|
||||
|
||||
#
|
||||
# Approach 1:
|
||||
#
|
||||
# Time Complexity:
|
||||
#
|
||||
def remove_vowels(s)
|
||||
end
|
||||
|
||||
s = 'leetcodeisacommunityforcoders'
|
||||
print(remove_vowels(s))
|
||||
# => "ltcdscmmntyfrcdrs"
|
||||
s = 'aeiou'
|
||||
print(remove_vowels(s))
|
||||
# => ""
|
Loading…
Reference in a new issue