Motivated frontend developer with a strong theoretical background and extensive hands-on practice in modern web technologies, including React and TypeScript.
Passionate about writing clean, efficient, and scalable code. Focused on performance, code quality, and UI consistency.
Experienced in building personal and training projects, solving a wide range of real-world problems, and continuously improving development skills through deep exploration of frontend tools and best practices.
function chooseBestSum(maxDistance, townsToVisit, distances) {
let bestSum = 0;
function findCombination(townsLeft, start = 0, currentSum = 0) {
if (townsLeft === 0) {
if (currentSum <= maxDistance && currentSum > bestSum) bestSum = currentSum;
return;
}
for (let i = start; i < distances.length; i++) {
if (currentSum + distances[i] > maxDistance) continue;
findCombination(townsLeft - 1, i + 1, currentSum + distances[i]);
}
}
findCombination(townsToVisit);
return bestSum > 0 ? bestSum : null;
}