Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
| 713. Subarray Product Less Than K | [Link](https://leetcode.com/problems/subarray-product-less-than-k/) | [Link](./lib/medium/713_subarray_product_less_than_k.rb) | [Link](./test/medium/test_713_subarray_product_less_than_k.rb) |
| 720. Longest Word in Dictionary | [Link](https://leetcode.com/problems/longest-word-in-dictionary/) | [Link](./lib/medium/720_longest_word_in_dictionary.rb) | [Link](./test/medium/test_720_longest_word_in_dictionary.rb) |
| 725. Split Linked List in Parts | [Link](https://leetcode.com/problems/split-linked-list-in-parts/) | [Link](./lib/medium/725_split_linked_list_in_parts.rb) | [Link](./test/medium/test_725_split_linked_list_in_parts.rb) |
| 729. My Calendar I | [Link](https://leetcode.com/problems/my-calendar-i/) | [Link](./lib/medium/729_my_calendar_i.rb) | [Link](./test/medium/test_729_my_calendar_i.rb) |
2 changes: 1 addition & 1 deletion leetcode-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'English'
::Gem::Specification.new do |s|
s.required_ruby_version = '>= 3.0'
s.name = 'leetcode-ruby'
s.version = '7.5.1.1'
s.version = '7.5.2'
s.license = 'MIT'
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
s.executable = 'leetcode-ruby'
Expand Down
20 changes: 20 additions & 0 deletions lib/medium/729_my_calendar_i.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

# https://leetcode.com/problems/my-calendar-i/
class MyCalendar
# Init
def initialize
@calendar = []
end

# @param {Integer} start_time
# @param {Integer} end_time
# @return {Boolean}
def book(start_time, end_time)
@calendar.each { |iv| return false if iv[0] < end_time && iv[1] > start_time }

@calendar << [start_time, end_time]

true
end
end
15 changes: 15 additions & 0 deletions test/medium/test_729_my_calendar_i.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/medium/729_my_calendar_i'
require 'minitest/autorun'

class MyCalendarITest < ::Minitest::Test
def test_default_one
my_calendar = ::MyCalendar.new

assert(my_calendar.book(10, 20))
assert(!my_calendar.book(15, 25))
assert(my_calendar.book(20, 30))
end
end
Loading