Skip to main content

All Questions

3 votes
1 answer
91 views

Merge discrete integer intervals

What it does The code starts with a set of integer intervals, and can add new intervals (possibly by updating existing intervals). Essentially, it is a bit array whose index starts at ...
FromTheStackAndBack's user avatar
2 votes
3 answers
198 views

Efficiently tagging first and last of each object matching condition

How can I make the code more readable and more efficient? (provided code is O(n²) time, but intuition says it can be pre-processed and done in O(n) time) Description it tags the first and last of ...
FromTheStackAndBack's user avatar
1 vote
2 answers
116 views

A simple performant factorial function

I am new to algorithm and data structure. After a little introduction to the topic, I have decided to implement a function called calculateFactorial, which takes an integer and calculates its ...
Napoleon Bonaparte's user avatar
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
341 views

Count matching pairs (modular equality)

Problem Given an array of natural numbers a. Find the number of such pairs of elements (a_i, a_j), where ...
EzioMercer's user avatar
2 votes
1 answer
145 views

Finding the 4 squares that sums up to a given number

I wrote this algorithm in JS with the main goal that it will give an answer for 10^750-10^1000 in 2-3 seconds but it solves 10^150 in 2-3 seconds so I am a little far from my goal, the problem is ...
user avatar
2 votes
2 answers
118 views

Find differences between two arrays

I have to identify added and deleted items between two objects with the same structure. ...
Elias Bobadilla's user avatar
1 vote
2 answers
147 views

"Frequency Counter Pattern", Can we get other better algorithm having like, O(n) or O(n log n)

Problem Statement : Write a function called matchSquare, which accept two arrays (arr1, arr2) Criteria: The function should return true, if every value in the arr1, has its corresponding values ...
RONE's user avatar
  • 131
1 vote
1 answer
233 views

Find a secret word given an array of triplets? (codewars problem)

The rules for the puzzle are: Each triplet has the rules of how the letters are ordered in the secret word (each letter is followed by the next letter inside the triplet array). all the letters of ...
Jonas's user avatar
  • 131
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 votes
1 answer
1k views

Finding the minimum bounding box of a rotated rectangle [closed]

...
Ryan Peschel's user avatar
1 vote
3 answers
80 views

Javascript: Reducing redundancy of notation nested value

Hello I have this function that looks for nested value 3 levels deep currently ...
Mateen Kazia's user avatar
1 vote
1 answer
180 views

Maximum Profit in Job Scheduling - Performance Issue

I implemented the Maximum Profit in Job Scheduling algorithm in JavaScript, but I'm having performance issue. The problem: We have n jobs, where every job is scheduled to be done from startTime[i] to ...
myTest532 myTest532's user avatar
3 votes
2 answers
76 views

Javascript best way to filter out empty values and simplify reusable function

Hello I have this function that takes array of objects and takes a specific value from the object and creates array of strings that can make mapped to dropdown selector. ...
Mateen Kazia's user avatar

15 30 50 per page
1
2 3 4 5
7