Ronin
BAN USER
Questions (2)
Comments (8)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
If someone could explain, Hows does the Hashtable / Hashset method work in O(n)?
Is this the correct implementation for that?
import java.util.*;
public class hash
{
public static void main( String[] args )
{
HashSet<String> set1 = new HashSet<String>();
set1.add( "ape" );
set1.add( "cat" );
set1.add( "bat" );
HashSet<String> set2 = new HashSet<String>();
set2.add( "bat" );
set2.add( "fox" );
set2.add( "ape" );
System.out.println( "1 = " + set1 + ", 2 = " + set2 );
set1.retainAll(set2); //Keep entries which exist in both
System.out.println( "Intersection = " + set1);
}
}
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Used to test your understanding of the difference between sizeof and strlen I suppose,
- Ronin February 27, 2008sizeof would be 100 bytes and as abc said - strlen would be random characters, on my compiler it seems to default to 4 bytes. I can't understand why this would be the case... anyone?