Amazon Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: Written Test
Multiply the binary numbers 110111 and 100100. Convert the numbers to decimal to prove your answer
class Program
{
static void Main(string[] args)
{
int tmpHash;
Hashtable table = new Hashtable(10);
PhoneBookData user1 = new PhoneBookData() { Name="Hemant", EmailId="h@Hotmail.com", PhoneNumber="123456789" };
tmpHash = CalculateHash(user1.Name);
table.Add(tmpHash,user1);
}
private static int CalculateHash(string p)
{
byte[] tmpsource = Encoding.ASCII.GetBytes(p);
int sum = 0;
foreach (var item in tmpsource)
{
sum = sum + Convert.ToInt16(item);
}
return sum / 10;
}
}
public class PhoneBookData
{
public string Name { get; set; }
public string PhoneNumber { get; set; }
public String EmailId { get; set; }
}
How can you "Compare performance" in a written test?
- Mike August 30, 2012