Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
Advice
1 vote
4 replies
196 views

I want to learn Data Structures, Algorithms, and Big-O notation from scratch, but there are too many resources online and it’s difficult to determine which ones are trustworthy or widely used by ...
Advice
0 votes
4 replies
162 views

here is my solution to the leetcode "longest consecutive sequence" problem: class Solution: def longestConsecutive(self, nums: List[int]) -> int: if len(nums) == 0: ...
-3 votes
1 answer
197 views

The algorithm I've written for an assignment is closely related to this monotonic stack approach https://www.geeksforgeeks.org/dsa/next-greater-element/ Best case: n pushes → Time complexity: O(n) ...
2 votes
3 answers
120 views

Let's say I have this pseudocode: int n = 100 for (int i = 1; i<=n; i++) System.out.println("Hello!"); for (int j = 1; j<=n; j++) System.out.println("World!!!"); end ...
0 votes
1 answer
68 views

Considering elements as a list of objects (already loaded in memory, not a DB query) and given the following portion of code: var filteresElements = elements.Where(el => el.Flag == true).Select(el....
4 votes
2 answers
280 views

int k = 0; for (int a = n; a >= 1; a /= 2) for (int b = a; b >= 1; b--) k++; cout << k; I would say that the answer is O(n), but the book where I have found the exercise says that ...
1 vote
2 answers
214 views

Suppose we want to generate a 5-digit unique student ID i.e. there are N = 100,000 possible values (from 00000 to 99999). What is the big O of the algorithm below? - while True: - Generate a random ...
0 votes
1 answer
105 views

What is the time cost (asymptotically) of the following method?: void fillList(int i) { list = new int[i]; } I have been told that it takes O(1) time because no initialization is done and the ...
0 votes
1 answer
73 views

I was doing leet code and came across https://leetcode.com/problems/two-sum/description/, which I've tried solving with a seen counter using hashmap. Below is the code: class Solution: def twoSum(...
-1 votes
1 answer
42 views

Is the complexity defined by the big-O notation e.g., n! is always more complex than n^3, regardless of the value of n? What if I know n = 3? Would I be able to say that in this case O(n!) is less ...
0 votes
1 answer
117 views

I'm looking at one of the solutions to the programming problem: Partition a Set into Two Subsets of Equal Sum. The programming problem: Given an array arr[], the task is to check if it can be ...
0 votes
2 answers
104 views

I am confused by the space complexity of the function below: int sumArr(int a[], int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum += a[i]; } return sum; } In ...
2 votes
0 answers
37 views

Whether it is BFS or DFS, is it (MN)^(MN)? There're M*N nodes and, in the worst case, all the nodes have edges between each other.
0 votes
0 answers
73 views

I'm trying to analyze the time complexity of the following recurrence relation using the recurrence tree method: T(n) = T(n - sqrt(n)) + n^2 The challenge I'm facing is determining the height of the ...
5 votes
1 answer
122 views

I'm having trouble understanding why the first function below is asymptotically 2^n, whereas the second is 3^n. I understand that solving the recursion equation yields these results, but am having ...
Joshua's user avatar
  • 59

15 30 50 per page
1
2 3 4 5
...
459

AltStyle によって変換されたページ (->オリジナル) /