HackerRank Code "Determining DNA Health"
The Algorithm
This has a bad worst-case complexity,
for (int i = first; i &lt;= last; i++) {
    for (int index = d.indexOf(genes.get(i)); index &gt;= 0; index = d.indexOf(genes.get(i), index + 1)) {
        sum += Integer.parseInt(health.get(i));
    }
}

Consider a strand &quot;aaaaaaaaaaaaaaaaaaaaaaa&quot; and genes {&quot;aaaaa&quot;, &quot;aaaaa&quot; ...
Now for every gene, at almost every position of the strand, there will be a string comparison. The amount of character comparisons is approximately TotalSize(genes) * strand.length, so that can easily lead to a TLE if the data is a little annoying, which of course it will be.
Here are a couple of other techniques you could try,

Building a suffix array and LCP array for the strand, so for every gene the number of occurrences in the strand can be counted in O(geneLength + log strandLength) (so without even visiting the occurrences!) by binary-searching for the start and end of the contiguous range in the SA that contains all those occurrences. A suffix trie is good as well but more dangerous for the memory footprint. SA and suffix trie can both be constructed in linear time (in the length of the string), but it is non-trivial to implement. The LCP array can be given as a secondary result of SA construction (depending on the algorithm) or otherwise created in linear time as well by using the SA.
Building a trie with the healthy genes, then go over the strand while descending down the trie, backing up as needed. This has a bunch of edge-cases that need to be considered. There are slow cases, for example if a gene is very big (half the length of the strand) and matches nearly everywhere (for example if the strand and gene are both only the same character), which I think is still a quadratic case. Some additional trickery may be able to work around that.

The solutions that I could find quickly seemed to use the second approach, but I think the first one would be a &quot;safer&quot; choice in terms of avoiding a quadratic worst-case complexity, though the second one seems useful enough in practice (it has been successfully used, after all).
Unnecessary Map
When the keys of a map are a dense and non-changing range of integers like this,
Map&lt;Integer, String&gt; genes = new HashMap&lt;&gt;();
for (int i = 0; i &lt; n; i++) {
    genes.put(i, genesItems[i]);
}

Using an ArrayList or plain array is a little more efficient and maybe more convenient (the array genesItems is already available anyway). Though of course this does not significantly contribute to TLEs in competitive programming.
The skeleton code under the problem uses arrays.
Avoid re-parsing
The inner loop contains Integer.parseInt(health.get(i)), but that should usually be done up front when reading in the problem data. The skeleton code under the problem parses up front.