Amazon Interview Question for SDE-2s


Country: United States




Comment hidden because of low score. Click to expand.
0
of 0 vote

VotingOccation
Name
StartDateTime
EndDateTime
Candidates[]

VotingOccationAddress
VotingOccation
Address
AmountOfVotesCommunicated?
HasBeenProcessed
NoFraud

VotingOccationAddressResult
VotingOccation
Candidate
Address
NumberOfVotes

VotingOccationResult
VotingOccation
Candidate
NumberOfVotes

FraudInstance
VotingOccation
Address
Person
PersonVotes[]

Candidate
Name

Vote
VotingOccation
Candidate
VotingAddress
TimeStamp
HasBeenUploaded
HasBeenProcessed

Person
Name
SSN

VotingAddress
Address

VotingPerson
RegistrablePerson
VotingOccation
Address
IsRegistered
VoteTimeStamp?

PersonVote
VotingOccation
VotingPerson
VoteTimeStamp (no candidate)
HasBeenProcessed


----------------------------------------------------------

Distributed system:
Locations:
Each location (votingAddress) will have information about:
1) all incoming occations/the candidates
2) the people voting in that address for incoming occations (VotingPerson)
3) all the people (Person) that is VotingPerson for that address
Each location will:
1) Validate that the person can vote there AND hasn't voted yet for this election.
2) Register a vote (no known person but known candidate) and a personVote (known person, not known candidate)
3) Upload to the centralizer the amount of votes expected AFTER the voting day has finished
4) Sync the votes and the PersonVotes with the centralizer

Centralizer:
1) will download all the addresses votes and PersonVotes
2) ProcessLocalVotes
will process all addresses first (checking that they have votes in.)
This will be called many times until VotingOccationAddress only has "true"s
Will detect fraud (PersonVote for the same person in more than one Occation)
3) ProcessGeneralVotes
will process all the local votes into general votes.
4) Will allow to check what's the address for the person for this occation

void ProcessLocalVotes(VotingOccationAddress voa)
{
//validate that it's not processed yet

//Take N votes that have not been processed and accumulate into the VotingOccationAddressResult
//mark those votes as processed and accumulate the votes in the same transaction

//Take N votePeople that have not been processed and do fraud calculation
//if person hasn't voted (VotingPerson.TimeStamp == null)
//mark the timestamp
//else
//fraud

//if all the votes received (Vote for that address and that voting occation)
//matches the AmountOfVotesCommunicated and the PersonVote
{
//we check for frauds already committed on the previous check

//we mark the whole VotingOccationAddress as HasBeenProcessed
}
}

- Diego July 26, 2019 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More