Skip to main content
3 votes
2 answers
165 views

When looking up memoization in Haskell, I found this bit of code: memoized_fib :: Int -> Integer memoized_fib = (map fib [0 ..] !!) where fib 0 = 0 fib 1 = 1 fib n = ...
Alfy B's user avatar
  • 167
0 votes
1 answer
154 views

I have a mathematical function called in render loop (240Hz). It's a function of some (atomic) state that very rarely changes. It calls 3 times to std::log, twice to std::sqrt, once to std::sin. When ...
Tom Huntington's user avatar
0 votes
0 answers
52 views

How can the following recursion + memoization code be converted into a tabulation format dynamic programming solution? The code is working but I want to improve it. The challenge I am facing is ...
Elias El hachem's user avatar
0 votes
2 answers
89 views

I have an app with cards. Cards are fetched with useInfiniteQuery from React Query. I fetch new card each time I reach the end of the list. Backend sends offset and limit based responses of this ...
magrega's user avatar
  • 263
2 votes
2 answers
102 views

I have a simple scenario in which I want to access my store.entities, but only those which are active. I understand the following is bad because a new reference is given each time: const ...
kiwikodes's user avatar
  • 774
0 votes
0 answers
26 views

I'm stuck on this problem where I memoized the Dropdown component because it was causing infinite re-renders when I selected something from the dropdown. Now I'm facing an issue where everytime I ...
Alius's user avatar
  • 1
0 votes
1 answer
105 views

Just by using the commented code instead of making the recursive calls inside the max function, leads to incorrect result particularly with the following test case int main() { Solution obj = ...
Mohamed Samir's user avatar
1 vote
2 answers
163 views

Problem: Given an array that sums to 0, find the maximum number of partitions of it such that all of them sum up to 0 individually. Example: input: [-2, 4, -3, 5, -4] output: 2 (which are [[5, -2, -3]...
figs_and_nuts's user avatar
1 vote
1 answer
102 views

I’m trying to improve the performance of a computationally expensive JavaScript function by memoizing it. The function accepts multiple arguments, including objects. Here's an example: function ...
sonu's user avatar
  • 11
0 votes
1 answer
151 views

I was solving LeetCode problem 3290. Maximum Multiplication Score: You are given an integer array a of size 4 and another integer array b of size at least 4. You need to choose 4 indices i0, i1, i2, ...
souparno majumder's user avatar
0 votes
1 answer
58 views

class Solution { public: int countNeighborhoods(const vector<int>& houses) { int neighborhoods = 0; int m = houses.size(); for (int i = 0; i < m; i++) { ...
Shreshth Sharma's user avatar
2 votes
0 answers
131 views

I have a function like this in my library, which depends on a large subset of the inputs being pre-calculated: @cache def f(n, precompute): if n < len(precompute): return precompute[n] ...
qwr's user avatar
  • 11.5k
-3 votes
1 answer
129 views

Here are the two different ways of solving 0/1 knapsack using recursion. #include<bits/stdc++.h> using namespace std; #define vi vector<int> #define vb vector<bool> long long solve1(...
heman's user avatar
  • 3
3 votes
0 answers
66 views

While solving fabonocci problem using recursion and memoization in JavaScript, I got "Maximum Call Stack Exceeded" error when I try to run it with large inputs. To troubleshoot, I copied the ...
Bharadwaj Dasavaram's user avatar
0 votes
1 answer
56 views

I have the following problem , in the code I found many places where the createSelector was not implemented correctly and i want to change it to imporve performance in the frontend. Originally the ...
physicsuser's user avatar

15 30 50 per page
1
2 3 4 5
103