Skip to main content

All 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 ...
TAHER El Mehdi's user avatar
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: ...
TAHER El Mehdi's user avatar
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 ...
Nate Anderson's user avatar
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 ...
D_S_X's user avatar
  • 189
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: ...
D_S_X's user avatar
  • 189
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 ...
Михаил Спирин's user avatar
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: ...
user243125's user avatar
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 ...
Icepickle's user avatar
  • 825
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 ...
Arber's user avatar
  • 31
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 ...
jackdaw's user avatar
  • 143
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 ...
leonheess's user avatar
  • 161
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 ...
daksh bhardwaj's user avatar
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 ...
iRohitBhatia's user avatar
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 ...
Cory Harper's user avatar
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 ...
Cory Harper's user avatar

15 30 50 per page