Skip to main content

All Questions

Tagged with
4 votes
2 answers
6k views

How exactly indexing works in arrays?

I only know that index is faster but don't know why is it faster. Suppose I have an array int[] a = {2,3,6,7}. Then I will try to find the element at a[3] and the speed of this will be O(1). Why? How ...
Asif Mushtaq's user avatar
2 votes
2 answers
3k views

Find the maximum number of pairs of numbers that are in a range, between two arrays

Lets say I have two arrays A and B A = {1,2,3} B = {12,11,67} and have max sum value S = 10 How many maximum number of unique pairs can be formed between the two arrays who's sum is less than or ...
WeirdAl's user avatar
  • 79
2 votes
2 answers
795 views

Non-fixed-size Fenwick Tree implementation

I'm planning to implement a non-fixed-size Fenwick tree. That is, a Fenwick tree that allows interleaving range queries with adding/removing elements. All implementations and samples I've seen so far ...
fps's user avatar
  • 139
1 vote
5 answers
6k views

Reverse subarray of an array with O(1)

I have an idea how to implement sub array reverse with O(1), not including precalculation such as reading the input. I will have many reverse operations, and I can't use the trivial solution of O(N). ...
Ilya Gazman's user avatar