|
U
Pro148. Compare O(N), O(N Log N), O(N²)
Med.
Problem Description
Compare O(N), O(N log N), O(N²), O(2^N), and O(N!) for increasing input sizes. Determine the largest feasible N under a fixed operation budget.
Input Format
- •Line 1: An integer N (1≤N≤105).
- •Line 2: N space-separated integers A1,A2,…,AN.
Output Format
Print the computed result (scalar integer or space-separated sequence).
Example 1:
Input:
5 3 1 4 1 5
Output:
1 1 3 4 5
Explanation: Processing input sequence according to algorithmic invariants.
Example 2:
Input:
1 42
Output:
42
Explanation: Singleton input baseline verification.
Example 3:
Input:
4 -10 -5 0 5
Output:
-10 -5 0 5
Explanation: Handling negative and boundary values.
Constraints:
1 <= N <= 10^5-10^9 <= A[i] <= 10^9Time complexity target: O(N) or O(N log N)Auxiliary space target: O(1) or O(N)
Follow up:Can this algorithm be adapted to an online streaming setting where the entire input cannot be held in memory simultaneously?
1,180 Online
Code
|Loading Code Editor...
SavedLn 1, Col 1
param_1 =
param_2 =
Sandboxed Engine
Ctrl+Enter = Run | Ctrl+Shift+Enter = Submit