All Questions
125 questions
3
votes
2
answers
95
views
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 ...
1
vote
2
answers
1k
views
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 ...
2
votes
1
answer
257
views
Leetcode problem: minimum removal to make valid parentheses
I was working on this problem on leetcode
Question
Your task is to remove the minimum number of parentheses ( '(' or
')', in any positions ) so that the resulting parentheses string is
valid and ...
3
votes
1
answer
341
views
Algorithm Challenge: Fuzzy Search
I recently took part in an algorithm challenge to create a Fuzzy search with the following criteria:
Given a set array, create a function that receives one argument and returns a new array containing ...
2
votes
3
answers
415
views
Leetcode First Unique Character in a String code optimisation
I was working on First Unique Character in a String
Question
Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
Example 1:
...
2
votes
3
answers
1k
views
Find the 'n' most frequent words in a text, aka word frequency
I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name.
The ...
1
vote
2
answers
343
views
Leetcode 377. Combination Sum IV Javascript Memoization attempt
Problem Statement
...
1
vote
1
answer
524
views
Cheapest flights within k stops algorithm in JavaScript
The problem:
There are n cities connected by some number of flights. You are given
an array flights where flights[i] = [fromi, toi, pricei] indicates
that there is ...
2
votes
1
answer
227
views
Leetcode 3 sum code optimisation
I was working on 3sum problem on leetcode
Question
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the ...
3
votes
3
answers
348
views
Project Euler 50: Consecutive prime sum
I just finished solving Project Euler's 50th problem, but it's awfully slow. I'd like to hear your thoughts on my code's efficiency and practices.
Problem Statement
The prime 41, can be written as the ...
3
votes
1
answer
696
views
Optimizing code solution for Palindrome Index-Hackerrank
I submitted my solution for palindrome Index coding challenge but I get "test cases terminated due to time out error". My code is working and so I don't know what else to do to optimize it. Please ...
2
votes
1
answer
5k
views
Comparing version numbers with JavaScript
I have written a function that compares two version number strings (e.g. 1.2.0 and 1.2.2) and return 1 if the first string is greater, ...
2
votes
1
answer
926
views
Codewars: Prime Streaming (PG-13)
I'm timing out on Codewars' Prime Streaming kata. Below is my code:
...
2
votes
1
answer
1k
views
Codewars: Pick peaks
Pick peaks
Wrote my "hello world" on Thursday, so definitely a beginner. I know some Python, so not a novice to programming in general.
Question
For example, the array ...
3
votes
1
answer
2k
views
Maze path finder using Depth-First Search algorithm
I'm trying to resolve this kata from CodeWars.
Kata exercise
You are at position [0, 0] in maze NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). ...