New answers tagged

1

I would say this looks a lot better in performance function isPalindrome(str){ let isOk = true; for(let i=0; i < str.length/2 ; i++){ if(str[i] !== str[str.length - i -1]){ isOk = false; break;} } return isOk; } function generateAllPossibleSubstring(str = ''){ let result = new Set([]); for (let i = 0; i < str....


2

This looks great, enjoyable to read despite the repetition. package com.gr; Packages should associate with the author, so they should be something like com.github.lucifer.palindrome for example. But depending on whether this code is being published or not, it does not matter in this case. This would be a great exercise for object-oriented programming by ...


1

Having a common interface for the algorithm would solve the code duplication between tests for different implementations. You create a set of tests that any implementation of the interface should fulfill and then just throw different implementations at it (see the L in SOLID principles). For testing a large set of simple string inputs, put the valid entries ...


Top 50 recent answers are included