Java Micro Blog: Why is this code causing a timed out?

It’s my first post here. Anyways what is causing a timed out? There’s no loops in my code at all here.

class MicroBlog {
    public String truncate(String input) {
        if (input.length() <= 5) return input;
        return (input.substring(0, 5));
    }
}

Occasionally the test infrastructure is just overloaded. I would suggest making a change somewhere (eg adding a space) and running it again to see if the issue is transient or not.

It’s still happening even after doing many spaces or comments, or using tenaries. Will using StringBuilder or doing this locally might help? Have you solved this problem before?

I’ve been stuck on this problem for like 3 days and looking at other solutions the secret is offsetByCodePoints()…

1 Like