Win a copy of A Functional Approach to Java: Augmenting Object-Oriented Java Code with Functional Principles this week in the Functional programming forum!

since Jul 03, 2011

For More

Cows and Likes

Cows

Total received

0

In last 30 days

0

Total given

0

Likes

Total received

8

Received in last 30 days

0

Total given

151

Given in last 30 days

0

Forums and Threads

Scavenger Hunt

Ranch Hand Scavenger Hunt

Greenhorn Scavenger Hunt

Ok i got it anyways thanks for the help

8 years ago

ok i got it thanks for the help

8 years ago

Thanks for the reply sir,

My question is Set doesn't store duplicate then how 2 stack with similar content & similar hashcode is stored in Set lists?

My question is Set doesn't store duplicate then how 2 stack with similar content & similar hashcode is stored in Set lists?

8 years ago

My Main Set

My Temp Set

Suppose main Set contains

{{0,3}{1,2,4,5,6}}

Suppose tmp Set contains

{{5,6,8},{1,2,4,5,6}}

When I am doing

what I get in Set lists is

{{0,3},{1,2,4,5,6},{5,6,8},{1,2,4,5,6}}

So i thought why not to check their hashcode so I did

since the max size value is 5

Output is 1,2,4,5,6

1,2,4,5,6

twice which I don't want in fact I m using Set because i don't want duplicate Stack in Set lists

Where my Understanding is going wrong?

My Temp Set

Suppose main Set contains

{{0,3}{1,2,4,5,6}}

Suppose tmp Set contains

{{5,6,8},{1,2,4,5,6}}

When I am doing

what I get in Set lists is

{{0,3},{1,2,4,5,6},{5,6,8},{1,2,4,5,6}}

So i thought why not to check their hashcode so I did

since the max size value is 5

Output is 1,2,4,5,6

1,2,4,5,6

twice which I don't want in fact I m using Set because i don't want duplicate Stack in Set lists

Where my Understanding is going wrong?

8 years ago

Fist I m very sorry i didnt knew that editing my orignal post will have that impact, i will keep this thing in mind

Second thing is this question is asked to me in one of mine interview

Third ya still i dont know how to solve this problem by hands (because then only I can code it)

I have already spent hours trying to figure it out how this problem might me solved but no luck, so asked here, I guess there is some math involved in this type of questions so unless and until i don't have that particular topic of maths knowledge I wont be able to solve it.

Can you help please ?

Second thing is this question is asked to me in one of mine interview

Third ya still i dont know how to solve this problem by hands (because then only I can code it)

I have already spent hours trying to figure it out how this problem might me solved but no luck, so asked here, I guess there is some math involved in this type of questions so unless and until i don't have that particular topic of maths knowledge I wont be able to solve it.

Can you help please ?

8 years ago

I have corrected the question please have a look again , thanks for providing your hands to help me

8 years ago

Multiple “intervals” are to be given as tasks. Calculate the maximum work time (minutes) to assign to one worker

Implement the method “int Problem2#getMaxWorkingTime(List intervals)”.

Return the maximum time to work on a task when one worker takes it. Time assignment unit shall be based on tasks. (i.e. Task assignment shall be either to complete the whole task, or to do nothing for it.) The length of the interval, time required to complete the task, is calculated by subtracting "end time" from "start time". (e.g. If [12:00, 13:00] is given, the length of the task is 60 min.) Return 0 if the argument is null or an empty list. The argument (a list of “intervals”) must not contain null. The number of “intervals” must not exceed 10,000

In Figure 3 , work time is maximized when three tasks [“06:00”, “08:30”], [“09:00”, “11:30”], and [“12:30”, “14:00”], are assigned. Therefore, the answer is 390 (minutes).

Intervals = [06:00-08:30], [08:00-09:00], [09:00-11:00], [09:00-11-30], [12:30-14:00], [10:30-14:00] (which is shown in figure 3 also)

Total Intervals = 6

**What I have tried so far **

To me it appears to as a problem whose answer I can find simply by subtracting the Interval with max end-time i.e 14:00 with Interval which has smallest start-time, say 14:00 minus 06:00 answer is 480 minutes (since 6 to 14 has 8 hours in it so 8*60 minutes = 480 minutes) but the correct answer is 390 minutes

Can any one please help me explaining how to solve this problem...?

The thing which I want to understand is out of 6 Intervals why only those 3 Intervals (mentioned above) is selected ?

Implement the method “int Problem2#getMaxWorkingTime(List intervals)”.

In Figure 3 , work time is maximized when three tasks [“06:00”, “08:30”], [“09:00”, “11:30”], and [“12:30”, “14:00”], are assigned. Therefore, the answer is 390 (minutes).

Intervals = [06:00-08:30], [08:00-09:00], [09:00-11:00], [09:00-11-30], [12:30-14:00], [10:30-14:00] (which is shown in figure 3 also)

Total Intervals = 6

To me it appears to as a problem whose answer I can find simply by subtracting the Interval with max end-time i.e 14:00 with Interval which has smallest start-time, say 14:00 minus 06:00 answer is 480 minutes (since 6 to 14 has 8 hours in it so 8*60 minutes = 480 minutes) but the correct answer is 390 minutes

Can any one please help me explaining how to solve this problem...?

The thing which I want to understand is out of 6 Intervals why only those 3 Intervals (mentioned above) is selected ?

8 years ago

Hi all,

Just a simple question, suppose i have given a I am iterating over list and inserting each element from list into BST, if time require to insert into BST is logn then what is the total time require to insert all the elements into tree ?

logn or nlogn ?

Just a simple question, suppose i have given a I am iterating over list and inserting each element from list into BST, if time require to insert into BST is logn then what is the total time require to insert all the elements into tree ?

logn or nlogn ?

8 years ago

Is this algo is an in-place, according to me yes, because tmp[] is consider as auxiliary space, so space complexity still remains O(1)

Do you agree with my answer if no please explain me too

thanks for your time and effort..!!

8 years ago

thanks for the answers...

i asked because when i was reading a placement crack book ...they used pointer size as well to determine the optimality of the code for a given problem .....

i asked because when i was reading a placement crack book ...they used pointer size as well to determine the optimality of the code for a given problem .....

9 years ago

hi all

what is the size of reference variable in Java ?

eg

what is the size of foo in my case ?

JVM is 32bit.

what i understand is ...

if JVM is 32bit , reference variable is of 4bytes since (8*4=32bit)

if JVM is 64bit , reference variable is of 8bytes since (8*8=64bit)

is my answer correct ??

what is the size of reference variable in Java ?

eg

what is the size of foo in my case ?

JVM is 32bit.

what i understand is ...

if JVM is 32bit , reference variable is of 4bytes since (8*4=32bit)

if JVM is 64bit , reference variable is of 8bytes since (8*8=64bit)

is my answer correct ??

9 years ago

thanks ..appreciate your input....

so conclusion is ..its O(n^2) ....

so conclusion is ..its O(n^2) ....

9 years ago

Suppose i have written a method like this

9 years ago

Ulf Dittmer wrote:A few comments in no particular order.

1) In the client code, the ByteArrayOutputStream is unused and unnecessary.

2) If the file size exactly 1024 bytes? If it is larger, the code is sending partial content that will be corrupted. If it is smaller then the code sends too many bytes, again possibly corrupting the contents - the number of bytes in the packet should be what fis.read returns, not the size of the byte[].

3) Have you gotten this client/server pair to work? If not, start with that.

silly mistake ..filesize in kbs * 1024 = buffersize ...lolz...thanks mate!

9 years ago