Hi guys I'm working on the longest subsequence algorithm, the idea is to find the subsequence of numbers from an array. I'm using Ruby, so far I'm missing the l
for ( int i = 1; i < n*n*n; i *= n ) { for ( int j = 0; j < n; j += 2 ) { for ( int k = 1; k < n; k *= 3 ) { cout<<k*n;
Wondering what is the average runtime complexity for half sorted and half reverse sorted array. For example the array: [0,7,2,5,4,3,6,1], number on every even i
I am solving a problem: Given a list of integers nums, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. Fo
Say I have the below ruby hash nested hash_or_array = [{ "book1" => "buyer1", "book2" => { "book21" => "buyer21", "book22" => ["buyer23", "b
The public key encrypts a 48Char data, and the result is arranged according to the format of C1C3C2. C1 (randomly generating a point on the elliptic curve of SM
let arrr = [7, 9, 30, 40, 50, 8, 1, 2, 3, 40, 90,2, 88,1]; output=[0, 1, 2, 3, 4, 5, 6, 7, 8 ,10, 12 ] I saved this code at javascript playgroun
I'm tring to use an algorithm for finding and ranking continuing decreases in my data. The base condition: The breakpoint location (blue arrow) is unknown but b
I need an Algorithm that I will use to scan pixels out from the center. Problem is with different lengths and sizes, it sometimes can't get to the position (See
I am trying to print all the paths from root to leaf in a tree, but having some issues collecting the path items. Consider the following graph: In my case thou
I am trying to find the minimum length cycle in a directed graph but this time using a greedy algorithm. I think the smartest way to do it is using Dijkstra's A
Assume that I have an array like this [[0, 1, 0, 0], [1, 0, 2, 5], [0, 2, 0, 0], [0, 5, 0, 0]] each index is a node index so [0, 1, 0, 0] means node0 has a edge
Please I was learning from the book Introduction to algorithm (Chapter 31 page 957) and came across this pseudocode. This pseudocode is how we can implement the
Can anyone help me please. I need to find the peak and troughs in a data series but with 2 conditions which are: Peak or trough is peak for minimum of n(days) L
Recently i saw a competitive coding question, the bruteforce approach doesn't meet the time complexity, Is there any other solution for this, Question: An expan
How to use latex to implement the multi-column algorithm in the link below, thank you very much. multi-column algorithm
Say I have a cyclic graph containing bi-directional and parallel edges e.g. Assume all edge weights equal 1. How would I determine if the shortest path is a un
Let k be a positive integer. Is it possible to find out the value of 3^k in mod 1000000007? I have written a C program code to do this but it gives a message on
The algorithm is for calculating 2^n recursively. I have used the Master theorem to determine that the time complexity is indeed O(log n) which seems to correct
I wrote this code to solve a problem called minimum number of jumps which basically asks what are the minimum number of jumps it takes to get from the beginning