Code Challenges
Learning a new language always implies solving problems, in this post I will put two exercises that might help you to test your skills on any language, in my case I solved them to be more confident programming in rust. I searched for problems with practical applications to make them more interesting.
Intersection Over Union (IoU)
This one is used in object detection, Let A and B being two rectangles described by their up left and down right corners.
- For example let
A
andB
be:
A = {up_left: {x: 0, y: 0}, down_right: {x: 5, y: 5}}
B = {up_left: {x: 2, y: 3}, down_right: {x: 4, y: 4}}
xy
axis are configured in the following way:
+---------------->(x)
| . . . . . . . .
| . . . . . . . .
| . . . . . . . .
| . . . . . . . .
| . . . . . . . .
| . . . . . . . .
| . . . . . . . .
v
(y)
Given any A an B return the Intersection over union between both rectangles
DNA Sequencing
The DNA Sequence is composed of a series of nucleotides abbreviated as ‘A’, ‘C’, ‘G’ and ‘T’.
- For example “ACGAATTCCG” is a DNA sequence
Given a string s
: that represents a DNA sequence, return all
10
-letter-long sequences (substrings) that occur more than once in a DNA
molecule. You may return the answer in any order.
Example 1:
Input: s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"
Output: ["AAAAACCCCC","CCCCCAAAAA"]
Example 2:
Input: s = "AAAAAAAAAAAAA"
Output: ["AAAAAAAAAA"]