Skip to content

Tag: algorithm

What is Big O in this example of code, O(N) or O(N^2)?

Can you please explain what is Big O in this example of code? Answer It depends entirely on your definition of n. If you define n to be the number of cells in the 2d matrix, then this nested loop is of linear complexity O(n) in relation to it. On the other hand, if you define n to be the

Appending item on same index

I have these indexes: [3,1,1,2] which shows position for every element in the first list And I need to append these items to that corresponding indexes: to list, to be like in this particular order, so after the item is inserted on the index and the next item is again pointing to the same position, the first …

Palindrome question use of lambda and key

Hey guys so I was working on this problem on the algoExpert platform, but I am struggling to understand what longest and currentLongest are really doing. Just from the beginning, I am not entirely sure what the currentLongest = [0, 1] is doing, is it just saying that it will have 2 values? Are odd and even re…

Finding MACD Divergence

I want to create a loop to automate finding MACD divergence with specific scenario/criterion, but I am finding it difficult to execute although its very easy to spot when looking at chart by eyes. Note: you can easily get this as ready available scanner but i want to improve my python knowledge, hope someone …