All Questions
45 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 ...
4
votes
2
answers
66
views
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:
...
3
votes
2
answers
324
views
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 ...
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 ...
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:
...
1
vote
0
answers
372
views
Codewars: Path Finder
Task
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). Return true if you can reach position [N-1, N-1] or false ...
1
vote
3
answers
398
views
Find the 10001st prime number
Project Euler 7: What is the 10 001st prime number?
I currently have this code:
...
6
votes
7
answers
1k
views
Verifying if a string can be created with the letters of another string
This is basically based on the following question on stackoverflow which was based on a codewars assignment that can be found here
Problem statement
Complete the function ...
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 ...
4
votes
2
answers
301
views
Maxcounters in JavaScript
I am trying to solve this question: MaxCounters.
Solving it is straightforward, but solving it fast enough is proving very difficult. How can I improve the performance of this code? At the moment it ...
0
votes
2
answers
1k
views
Sherlock and Anagrams in Javascript
I am trying to solve a Hackerrank problem Sherlock and Anagrams. I think my code is valid but somehow times out for some of the test cases. Any tips on how to improve its performance? Critique ...
5
votes
2
answers
520
views
Frequency Queries (Hackerrank)
This is the problem:
You are given queries. Each query is of the form two integers described below:
1 x: Insert x in your data structure.
2 y: Delete one occurrence of y from your data ...
4
votes
2
answers
429
views
two-sum algorithm
Can someone help me in optimizing the code here?
This is the original question
Given an array of integers, return indices of the two numbers such
that they add up to a specific target.
You ...
3
votes
1
answer
627
views
Find a Sum of Particles in A Set of Boxes Given a Number of Rows and Columns
This is a code challenge, from Codewars, the details of the specific challenge in depth can be found here: https://www.codewars.com/kata/magnet-particules-in-boxes/javascript.
The summary of it ...
3
votes
1
answer
567
views
Find A Series of Numbers Who when Squared and Summed are equal to a given Square
I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript
I have a working solution, the ...