Category: c / c++
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You …
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. This is an data-structure problem that you would need to come up with …
For example, Given nums = return 2. Note: Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity? How many solutions …
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110000010100101000000). Follow up: If …
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the …