Vitaly.Arbuzov
BAN USERYou should have second array count with count[i][j] = number of live cells near it.
Basing on that array you will build next generation board.
Transformation will be always o(N^2) but there are many optimizations that could be applied on 3-rd and higher steps (e.g. run not through all the board but just through cells that could change their state)
sorry, i thought that you should count how many pairs there are <k. For largest sum function should return sum itself and you should store max return value it will be result.
- Vitaly.Arbuzov January 27, 2011Tree based solution is easy to implement but will take O(n^2) in worst case (consider sorted list of appointments that does not overlap).
O(N) still not found.
The best answer!
- Vitaly.Arbuzov January 26, 2011The easies solution i hope...
1) Sort both arrays A[] and B[]
2) result = 0;
for each b in B {
result += countElementsThatAreLessThan(k - b);
}
Where countElementsThatAreLessThan is simple binary search function that finds index of last element in A that is less than given value;
O(nlogn)
RepHi, my name is Ethel Olson, and I'm a record clerk for the city of Hamburg. I am searching ...
Repmorganswitzer8475, Android test engineer at ABC TECH SUPPORT
Hey, I'm Morgan switzer and i am a sociologist. I also like to read some interesting books like get ...
RepMichLang, Apple Phone Number available 24/7 for our Customers at ADP
The role of an office machine operator may seem mundane at first glance, but it plays a crucial role in ...
Good implementation of equals method should have o.getClass().getName().equals(this.getClass().getName())
- Vitaly.Arbuzov January 27, 2011equals should be reflexive, symmetric and transitive.
In case you add property to Student2 you'll break symmetric of relation so that student2.equals(student1) will be false and student1.equals(student2) will be true;