Leandro Coutinho

Ranch Hand
+ Follow
since Mar 04, 2009
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Leandro Coutinho

Ryan McGuire wrote:I know you said you get it now but I'll answer anyhow:

Leandro Coutinho wrote:Thanks a lot Ryan!
if ((A[i] >> bit & 1) != (A[j] >> bit & 1)) {
and not:
if (A[i] >> bit != A[j] >> bit) {
I tested and it gave the same result for all examples.

No it doesn't. If A[i] = 3, A[j] = 1, and bit = 0, then A[i]>>bit & 1 == A[j]>>bit & 1, but A[i]>>bit != A[j]>>bit.

Yes, it does. Because bit won't reach 0, it stops when bit = 1.

Ryan McGuire wrote:That guts of that if() figures out the value for that bit in B that would make C[i] < C[j] (with i < j). For instance, in the case above where A[i] = 01111 and A[j] = 01001 (with i < j), when bit=2, we would want to set bit 2 of B to a 1. That way, bit 2 of A[i] would get XORed from a 1 to a 0 and bit 2 of A[j] would get XORed from a 0 to a 1, which would make C[i] < C[j].

Got it.

In the first example:
{3, 2, ...}

i = 0, j = 2

They differ in bit 0, then ++profits[0][]
And to make the changes, the 0 bit of B must be 1, then ++profits[0][1]

Thanks a lot Ryan.
Thanks a lot Ryan!

Ryan McGuire wrote:The value for B is a number numBits bits long with each bit set to whichever value has a higher value in profits[bit][].

Really cool.

So "int bit = numBits - 1", to get the high order bit.
If "int bit = numBits" it would right shift all bits and the number would be zero.

When A[i] < A[j], then A[i] >> bit & 1 equals 0. So:
++profits[bit][A[i] >> bit & 1]; => ++profits[bit][0];

if ((A[i] >> bit & 1) != (A[j] >> bit & 1)) {
and not:
if (A[i] >> bit != A[j] >> bit) {
I tested and it gave the same result for all examples.

In the example "0)", it says that only B=3 returns 8, but debugging it shows that B could also be =2:
profits[0][0] = 1
profits[0][1] = 4
profits[1][0] = 4
profits[1][1] = 4


It's still not clear to me where the xor happens (if it happens).
And I don't understand how he came up with this idea of finding B and the number of pairs and why it works. I'll think more hard here and work through the examples to find out.

Thanks again.

I read the problem's solution but couldn't understand it. So could someone here explain for me how the code works, please?

Problem: http://community.topcoder.com/stat?c=problem_statement&pm=13657&rd=16313

I understand the syntax, but not the logic behind this.

Thanks a lot!!

The place on our profile that shows the likes that we gave and that we received could have a link for those posts.

Thank you.

5 years ago

George Mournos wrote:
So, in your example of the "order by" columns, if one does an IDOR attack and substitutes one "order by column" with another, he could order results in ways for which his has no access. This is not an attack (no impact)!!!

I think this can be used as an attack. For example if someone can only see a list of the last 10 suppliers, then order by some other thing like supplier owner or contract value. Probably a poor example, but I think there are some cases that this can be bad.
5 years ago
I got surprised with the result. I thought instances of the super classes were always created before the child classes, but, based on the result, it seems that it is not what happen.
It's more like the not private members of the super class are included inside the child class, and you can use "super" and "this" more like a namespace ...

What are the main benefits that Java 7 brings for concurrence, threads, parallel programming?
What would be very hard or not possible to do with Java 6?

Thank you!

ps: Congratulations for the book. I seems to be pretty good. I'm reading the sample chapter, and I like it because there are real examples, real code and doing is a very good way to learn.
Problem SOLVED!!! YEAH! hehe

I had the AffableBeanPool in the JDBC Connections Pools, but didn't have jdbc/affablebean in JDBC Resources.
Glassfish Admin Console -> JDBC -> JDBC Resources -> New
8 years ago

Maurice Rogers wrote:I think the problem I was experiencing was due to a space in one of my configuration files.

Double check your xml config to make sure that the connection source is as it should be....


8 years ago
Same error following the example. I think the problem is that Glassfish is not deploying the driver.

It doesn't appear Deploying driver in my console. I put the jar file in the same location. I also in the project's lib folder. Restarted the server but it didn't work.

Please. Someone help us.

My output:
Copying 1 file to /home/leandro/NetBeansProjects/AffableBean/build/web/WEB-INF/lib
Created dir: /home/leandro/NetBeansProjects/AffableBean/build/generated/src
Created dir: /home/leandro/NetBeansProjects/AffableBean/build/generated/classes
Compiling 1 source file to /home/leandro/NetBeansProjects/AffableBean/build/generated/classes
Starting GlassFish Server 3.x
GlassFish Server 3.x is running.
Incrementally deploying AffableBean
Completed incremental distribution of AffableBean
Incrementally redeploying AffableBean
Browsing: http://localhost:8080/AffableBean/faces/test/testDataSource.jsp
BUILD SUCCESSFUL (total time: 40 seconds)
8 years ago

What's the output?

a) Compile error
b) 7


Lucas Smith wrote:Maybe you have to add some .jars to the classpath of your client, especially when you use the client outside the container,
For example while using Glassfish there must be gf-client.jar.

ok. I'm using JBoss AS 7. I download this jbossall-client.jar from here: http://www.java2s.com/Code/Jar/JKL/Downloadjbossallclientjar.htm
Now I'm getting the exception below. How do I know which port to choose?