Skip to main content
Advice
0 votes
2 replies
23 views

Quicksort and Mergesort are both (before any optimisation) recursive algorithms that take up O(nlogn) stack space (ignoring Merge Sort's O(n) space complexity taken for the merging step). Upon ...
Lamphiq's user avatar
Advice
0 votes
2 replies
67 views

When defining a DP solution, the state is represented by the function's parameters, and the function returns the answer to that subproblem. For example in Fibonacci, the state is n and the return ...
lelek's user avatar
  • 1
Advice
1 vote
23 replies
196 views

this is a project in php but i am happy with any suggestions, regardless of language. the coding is less the issue than a missing piece in logic i am struggling with. users answer a series of 7-point ...
Avi Sato's user avatar
-2 votes
1 answer
179 views

I am implementing a custom Singly Linked List in Java for a project, and I need to implement a method to reverse the list. The main constraint is that it must be done in-place (O(1) space complexity), ...
CRISTIAN JOSUE FLORES PLEITEZ's user avatar
Advice
0 votes
6 replies
145 views

In Dijkstra's algorithm, you need to select the nodes with the smallest distance (distance = priority in the Priority Queue which is implemented by a MIN heap) You also need to update the distances of ...
Game Development's user avatar
Advice
0 votes
6 replies
180 views

So I was solving Rearrange Array Elements by Sign (LC #2149) What I wrote: public int[] rearrangeArray(int[] nums) { int nPointer = 0, pPointer = 0; int[] result = new int[nums.length]; ...
Mayank Grover's user avatar
Best practices
0 votes
1 replies
78 views

What is the most common way to perform range filling algorithm in hardware (e. g. in Verilog)? Problem: given 2 N-wire buses, need to provide resulting 2^N bus with those bits asserted, which are ...
Ivan Sladkov's user avatar
-2 votes
1 answer
186 views

I'm trying to solve this problem https://open.kattis.com/problems/savez Basically you get N strings where the i-th string is denoted by x[i]. you want to find the length of longest special subsequence ...
Isabella's user avatar
  • 103
Advice
0 votes
7 replies
135 views

I am looking for a way to implement such hashing. const str1 = "abc" const str2 = "zyx" const hash1 = hash(str1+str2) const hash2 = hash(str2+str1) // expecting hash1 to be equal ...
bel's user avatar
  • 469
Advice
0 votes
6 replies
144 views

To build a heap from an array, we take a list of elements and start calling heapify on all non-leaf nodes, from the bottom, up When we add an element to a heap, we simple bubble it up Won't bubbling ...
Game Development's user avatar
0 votes
2 answers
194 views

I've seen other books and articles do it differently, so I'm just wondering if I got it right or wrong. I have nested the right child check within the left child check. I've seen implementations ...
Game Development's user avatar
Advice
0 votes
3 replies
148 views

I know that there are many different types of sorting algorithms. But how do I know what algorithms do better jobs at certain questions and which ones take longer to run but are better at other things?...
Lucas Li's user avatar
Tooling
1 vote
7 replies
288 views

The Simpsons have constructed a cinema with R rows (4 ≤ R ≤ 500) of seats in the shape of a rectangle with an odd width W (7 ≤ W ≤ 501). The distance between two adjacent seats in the same row is ...
Lucas Li's user avatar
1 vote
1 answer
220 views

I'm new to the C language (I'm doing CS50x) and I want to code a merge sort algorithm. I want to debug my code but I can't figure out why malloc in sort_disassemble is crashing. P.S. The code isn't ...
Crucial Beauty's user avatar
Advice
1 vote
4 replies
143 views

def find_suffix_chain(word: str, start_pos: str, root: str, current_chain: List = None, visited: Set = None, shared_cache: dict = None) -> List: &...
LeBron James's user avatar

15 30 50 per page
1
2 3 4 5
8099