Skip to content

Commit acf8874

Browse files
authored
Merge pull request #631 from fartem/2446_Determine_if_Two_Events_Have_Conflict
2024-05-23 v. 5.7.4: added "2446. Determine if Two Events Have Conflict"
2 parents d03b960 + 42f4d07 commit acf8874

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,3 +434,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
434434
| 2427. Number of Common Factors | [Link](https://leetcode.com/problems/number-of-common-factors/) | [Link](./lib/easy/2427_number_of_common_factors.rb) |
435435
| 2432. The Employee That Worked on the Longest Task | [Link](https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/) | [Link](./lib/easy/2432_the_employee_that_worked_on_the_longest_task.rb) |
436436
| 2441. Largest Positive Integer That Exists With Its Negative | [Link](https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative/) | [Link](./lib/easy/2441_largest_positive_integer_that_exists_with_its_negative.rb) |
437+
| 2446. Determine if Two Events Have Conflict | [Link](https://leetcode.com/problems/determine-if-two-events-have-conflict/) | [Link](./lib/easy/2446_determine_if_two_events_have_conflict.rb) |

leetcode-ruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'English'
55
::Gem::Specification.new do |s|
66
s.required_ruby_version = '>= 3.0'
77
s.name = 'leetcode-ruby'
8-
s.version = '5.7.3'
8+
s.version = '5.7.4'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[bin/leetcode-ruby README.md LICENSE]
1111
s.executable = 'leetcode-ruby'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/determine-if-two-events-have-conflict/
4+
# @param {String[]} event1
5+
# @param {String[]} event2
6+
# @return {Boolean}
7+
def have_conflict(event1, event2)
8+
[event1[0], event2[0]].max <= [event1[1], event2[1]].min
9+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/2446_determine_if_two_events_have_conflict'
5+
require 'minitest/autorun'
6+
7+
class DetermineIfTwoEventsHaveConflictTest < ::Minitest::Test
8+
def test_default
9+
assert(have_conflict(%w[01:15 02:00], %w[02:00 03:00]))
10+
assert(have_conflict(%w[01:00 02:00], %w[01:20 03:00]))
11+
assert(!have_conflict(%w[10:00 11:00], %w[14:00 15:00]))
12+
end
13+
end

0 commit comments

Comments
 (0)