All Questions
Tagged with javascriptprogramming-challenge
290 questions
2votes
0answers
733views
Determine whether there exists a one-to-one character mapping from one string to another
The task Determine whether there exists a one-to-one character mapping from one string s1 to another s2. For example, given s1 = abc and s2 = bcd, return true since we can map a to b, b to c, and c ...
5votes
3answers
302views
Largest Triple Products without using sort?
I implemented the Largest Triple Products algorithm, but I use sort which makes my time complexity \$O(n *log(n))\$. Is there a way to implement it without a temporary sorted array? The problem: You'...
4votes
2answers
2kviews
Given a pivot x, and a list lst, partition the list into three parts
The task: Given a pivot x, and a list lst, partition the list into three parts. The first part contains all elements in lst that are less than x. The second part contains all elements in lst that are ...
21votes
6answers
4kviews
Find the longest word's length
The challenge is simple: Return the length of the longest word in the provided sentence. The solution is just as simple: ...
3votes
2answers
95views
Optimizing a Function to Check Pronic Numbers in JavaScript
I've written a function in JavaScript to check whether a given number is a Pronic number. A Pronic number, also known as an oblong number, rectangular number, or ...
4votes
2answers
66views
Optimizing a Function to Generate a Row of Consecutive Odd Numbers in a Triangle
I've written a JavaScript function that generates a row of consecutive odd numbers in a triangle. The triangle looks like this: ...
1vote
2answers
1kviews
Leetcode 55. Jump Game solution
I was working on Jump Game problem on leetcode Question You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your ...
0votes
1answer
102views
Advent of Code 2023 day 1: Trebuchet in JS, part 2
The task involves analyzing a bunch of lines containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and combining them ...
2votes
1answer
76views
Advent of Code 2023 day 1: Trebuchet in JS
The task involves analyzing a bunch of lines containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and combining them ...
1vote
1answer
75views
String represents a road. One character travels on the road obeying the stops - Code challenge (advent.js day 5)
This is my code to solve the 5th Adventjs challenge. In that link you can read the instructions. How can I improve it? It's a bit messy... and I'm repeating some part of the code. All must be in just ...
3votes
2answers
324views
Given an array, remove zero or more elements to maximize the reduction where you add odd values and subtract even values
Here's a code challenge I got. (I could not solve the challenge, I ran out of time. I rephrased the challenge language and I am trying the challenge again for personal growth & computer science ...
5votes
1answer
4kviews
Largest rectangle areas after drawing boundaries
I was asked the following question while trying to get a Hackerrank certificate. I couldn't solve on time but I now completed the solution. Can you please check if my solution seems good? Suggestions ...
5votes
1answer
323views
Find the starting indices of all occurrences of the pattern in the string - KMP algorithm follow-up
The task was initially solved here, but was too buggy: Given a string and a pattern, find the starting indices of all occurrences of the pattern in the string. For example, given the string "...
11votes
5answers
3kviews
A faster way to compute the largest prime factor
I am self-learning js and came across this problem(#3) from the Euler Project The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Logic:...
0votes
1answer
137views
A faster way to compute largest prime factor (Again, but a lot better)
I came up with this code after implementing the feedback given by @200_success. The previous one (A faster way to compute the largest prime factor) tested my patience, but still failed to give the ...