Maximum single-sell profit

I love this problem. It’s a classic interview question and depending on how you think about it, you’ll end up getting better and better solutions. It’s certainly possible to do this in better than O(n2) time, and I’ve listed three different ways that you can think about the problem here. Hopefully this answers your question! … Read more

Javascript ES6 computational/time complexity of collections

Right from that very paragraph your linked to: Set objects must be implemented using [mechanisms] that, on average, provide access times that are sublinear on the number of elements in the collection. You will find the same sentence for Maps, WeakMaps and WeakSets. It looks the ECMA spec mandates that the implementations (e.g. Set.prototype.has) are … Read more

Examples of Algorithms which has O(1), O(n log n) and O(log n) complexities

If you want examples of Algorithms/Group of Statements with Time complexity as given in the question, here is a small list – O(1) time Accessing Array Index (int a = ARR[5];) Inserting a node in Linked List Pushing and Poping on Stack Insertion and Removal from Queue Finding out the parent or left/right child of … Read more

Are there any cases where you would prefer a higher big-O time complexity algorithm over the lower one?

There can be many reasons to prefer an algorithm with higher big O time complexity over the lower one: most of the time, lower big-O complexity is harder to achieve and requires skilled implementation, a lot of knowledge and a lot of testing. big-O hides the details about a constant: algorithm that performs in 10^5 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)