Skip to main content

All Questions

4 votes
1 answer
525 views

calculate the number of ways to pick two different indices

I'm working on a codesignal practice problem You are given an array of integers a and an integer k. Your task is to calculate the number of ways to pick two different indices i < j, such that a[i] ...
Josh's user avatar
  • 41
3 votes
0 answers
40 views

Cross-classification of imagery from several regions in GEE

For a project I want to do the following: Use imagery from 17 different regions in Europe to train 17 RF classifiers Use those 17 classifiers to classify each of the regions It will be a multi-...
pottsbill's user avatar
1 vote
1 answer
230 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
0 answers
34 views

Pull pictures from folders on Google Drive and add them to a Sheet

I have code that I have been using for 2 years and it was working perfectly until recently. It started to give a timeout warning a couple of weeks ago and now it's not really running anymore. The code ...
Vivian Roberts's user avatar
2 votes
3 answers
400 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
0 votes
1 answer
205 views

Leetcode 662. Maximum Width of Binary Tree Javascript FlatMap attempt - Time Limit Exceeded

Problem Statement: Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels. The width of one level is defined as ...
Prashin Jeevaganth's user avatar
1 vote
2 answers
342 views

Leetcode 377. Combination Sum IV Javascript Memoization attempt

Problem Statement ...
Prashin Jeevaganth's user avatar
0 votes
2 answers
206 views

A function to find all the primes between two numbers whose reverse is also a prime and doesn't include palindrome, in JS

I am trying to solve a challenge in which I have to write a function that takes in two numbers as arguments and returns an array containing numbers between them which are prime and their reverse is ...
Valoruz's user avatar
  • 103
1 vote
1 answer
178 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
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 ...
myTest532 myTest532's user avatar
2 votes
2 answers
689 views

Keeping only every nth element in an array in JavaScript

I have two arrays, arr_of_frequencies and float_array, of the same length — around 500-800k values each. I have to get that down ...
Luke's user avatar
  • 123
2 votes
1 answer
216 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 ...
D_S_X's user avatar
  • 189
3 votes
1 answer
86 views

Count number of square integers in a given range of ints (faster function?)

The function below passes most test cases: ...
kennsorr's user avatar
  • 213
8 votes
2 answers
354 views

Minimize sum of array by applying specific operation on x carefully chosen elements

This code works, and solves the problem, but doesn't satisfy some time requirements, especially when the 'nums' array can have a length of over 1000. How can this be optimized? Just reference: This ...
kennsorr's user avatar
  • 213
4 votes
1 answer
1k views

Leetcode three sum in Javascript

I was doing 3sum question 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 sum ...
iRohitBhatia's user avatar

15 30 50 per page