Skip to main content
Mod Removes Wiki by Martin EnderMod
Post Made Community Wiki by Martin EnderMod
Post Merged (destination) from meta.codegolf.stackexchange.com/questions/1847/…
Post Merged (destination) from meta.codegolf.stackexchange.com/questions/638/…
deleted 153 characters in body
Source Link
EAKAE
  • 175
  • 4

Fastest Code: checking if interval pairs overlap

Given an unsorted input of many interval pairs (50+), write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input 1:
interval x , interval y

10-25, 50-60
10-15, 25-60

Output:
Can be in any true false format.

false (They overlap)

reasoning:

a.x overlaps b.x
a.y overlaps b.y

Example input 2:

10-25, 50-60
20-30, 25-30

Output:

true (they do not overlap)

reasoning:

a.x overlaps b.x
a.y does not overlap b.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime

Fastest Code: checking if interval pairs overlap

Given an unsorted input of interval pairs, write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input 1:
interval x , interval y

10-25, 50-60
10-15, 25-60

Output:
Can be in any true false format.

false (They overlap)

reasoning:

a.x overlaps b.x
a.y overlaps b.y

Example input 2:

10-25, 50-60
20-30, 25-30

Output:

true (they do not overlap)

reasoning:

a.x overlaps b.x
a.y does not overlap b.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime

Fastest Code: checking if interval pairs overlap

Given an unsorted input of many interval pairs (50+), write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input 1:
interval x , interval y

10-25, 50-60
10-15, 25-60

Output:
Can be in any true false format.

false (They overlap)

reasoning:

a.x overlaps b.x
a.y overlaps b.y

Example input 2:

10-25, 50-60
20-30, 25-30

Output:

true (they do not overlap)

reasoning:

a.x overlaps b.x
a.y does not overlap b.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime
deleted 153 characters in body
Source Link
EAKAE
  • 175
  • 4

Fastest Code: checking if interval pairs overlap

Given an unsorted input of interval pairs, write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input 1:
interval x , interval y
the a, b, ... is not required, was added for the explanation.

a:  10-25, 50-60
b:  20-30, 25-30
c:  10-15, 25-60
...

outputOutput:
Can be in any true false format.

false (They overlap)

reasoning:

interval a and b do not overlap:
  a.x overlaps b.x
  a.y does not overlapoverlaps b.y
interval

Example input 2:

10-25, a50-60
20-30, and25-30

Output:

true c(they overlap:
do not overlap)

reasoning:

a.x overlaps cb.x
  a.y overlaps c.y
interval b and c do not overlap:
  b.x does not overlap c.x
  b.y overlaps c.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime

Fastest Code: checking if interval pairs overlap

Given an input of interval pairs, write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input:
interval x , interval y
the a, b, ... is not required, was added for the explanation.

a:  10-25, 50-60
b:  20-30, 25-30
c:  10-15, 25-60
...

output:
Can be in any true false format.

false (They overlap)

reasoning:

interval a and b do not overlap:
  a.x overlaps b.x
  a.y does not overlap b.y
interval a and c overlap:
  a.x overlaps c.x
  a.y overlaps c.y
interval b and c do not overlap:
  b.x does not overlap c.x
  b.y overlaps c.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime

Fastest Code: checking if interval pairs overlap

Given an unsorted input of interval pairs, write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input 1:
interval x , interval y

10-25, 50-60
10-15, 25-60

Output:
Can be in any true false format.

false (They overlap)

reasoning:

a.x overlaps b.x
a.y overlaps b.y

Example input 2:

10-25, 50-60
20-30, 25-30

Output:

true (they do not overlap)

reasoning:

a.x overlaps b.x
a.y does not overlap b.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime
added 65 characters in body
Source Link
EAKAE
  • 175
  • 4

Fastest Code: checking if interval pairs overlap

Given an input of interval pairs, write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input:
interval x , interval y
the a, b, ... is not required, was added for the explanation.

a:  10-25, 50-60
b:  20-30, 25-30
c:  10-15, 25-60
...

output:
Can be in any true false format.

false (They overlap)

reasoning:

interval a and b do not overlap:
  a.x overlaps b.x
  a.y does not overlap b.y
interval a and c overlap:
  a.x overlaps c.x
  a.y overlaps c.y
interval b and c do not overlap:
  b.x does not overlap c.x
  b.y overlaps c.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime

Given an input of interval pairs, write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input:
interval x , interval y
the a, b, ... is not required, was added for the explanation.

a:  10-25, 50-60
b:  20-30, 25-30
c:  10-15, 25-60
...

output:
Can be in any true false format.

false (They overlap)

reasoning:

interval a and b do not overlap:
  a.x overlaps b.x
  a.y does not overlap b.y
interval a and c overlap:
  a.x overlaps c.x
  a.y overlaps c.y
interval b and c do not overlap:
  b.x does not overlap c.x
  b.y overlaps c.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime

Fastest Code: checking if interval pairs overlap

Given an input of interval pairs, write the fastest algorithm to determine if they do not overlap.

An interval pair is said to overlap if interval x and interval y are overlapping.

Example input:
interval x , interval y
the a, b, ... is not required, was added for the explanation.

a:  10-25, 50-60
b:  20-30, 25-30
c:  10-15, 25-60
...

output:
Can be in any true false format.

false (They overlap)

reasoning:

interval a and b do not overlap:
  a.x overlaps b.x
  a.y does not overlap b.y
interval a and c overlap:
  a.x overlaps c.x
  a.y overlaps c.y
interval b and c do not overlap:
  b.x does not overlap c.x
  b.y overlaps c.y

Scoring:

[not sure...]
brute force gives a worst case n^2 runtime
Source Link
EAKAE
  • 175
  • 4
Loading