This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write your MySQL query statement below | |
select id, name from Students where Students.department_id NOT IN (select id from Departments); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_vowels(s) | |
vowels = ['a', 'e', 'i', 'o', 'u'] | |
chars = s.chars | |
result = '' | |
chars.each do |c| | |
unless vowels.include?(c) | |
result << c | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def running_sum(nums) | |
sum = 0 | |
result = [] | |
for i in (0..nums.size-1) | |
sum = sum + nums[i] | |
result << sum | |
end | |
result | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
attr_accessor :data, :next_node | |
def initialize(data, next_node=nil) | |
@data = data | |
@next_node = next_node | |
end | |
def to_s | |
data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
attr_accessor :data, :next_node | |
def initialize(data, next_node=nil) | |
@data = data | |
@next_node = next_node | |
end | |
def to_s | |
data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
attr_accessor :data, :next_node | |
def initialize(data, next_node=nil) | |
@data = data | |
@next_node = next_node | |
end | |
end | |
class LinkedList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
attr_accessor :data, :next_node | |
def initialize(data, next_node=nil) | |
@data = data | |
@next_node = next_node | |
end | |
end | |
class LinkedList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
attr_accessor :data, :next_node | |
def initialize(data, next_node=nil) | |
@data = data | |
@next_node = next_node | |
end | |
end | |
class LinkedList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def encodings(s) | |
return 0 if s.include?('0') | |
if s.empty? | |
return 1 | |
elsif s.to_i < 10 | |
return 1 | |
else | |
result = encodings(s[1..-1]) | |
if s[0..1].to_i <= 26 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def replace_at(string, index, character) | |
return string[0, index] + character + string[index + character.length .. -1] | |
end | |
def remove_white_spaces(s) | |
return if (s.nil? || s.empty?) | |
read = 0 | |
write = 0 | |