Amazon Interview Question

Country: United States

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

Typically how antivirus searches malware or virus on the machine is by searching for its signature. These signatures are stored in the form of a pattern that antivirus searches across all files.
This use case will also fall in the same category where the required service will search for a malware pattern across photos and videos to see if they encode any malicious information.

For simplicity purposes, we will assume that photo and video will be converted from their binary stream format to base64 encoding. Base64 encoding of a photo/video will give us ASCII(text) representation of their contents.

We will keep the signature patterns of all the known malware in the map <Signature, malware name>. We can have multiple signatures for the same malware.

This problem will then translate to a substring search using a pattern. We can use Rabin-Karp or KMP algorithm to search for all the signature substrings across a stream of base64 encoded data that we scan/comes our way.

- Saurabh December 16, 2019 | Flag Reply

Add a Comment

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


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


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