ServiceNow
ServiceNow

Software Engineer

Best Time to Buy and Sell Stock

Medium
Round 1CodingCandidate Selected

You are given an array where each element represents the price of a stock on a given day. Write an algorithm to determine the maximum profit you can achieve by buying on one day and selling on another. Discuss the constraints and provide examples.

This question was asked in

ServiceNow Software Engineer Interview Experience

The interview process at ServiceNow consisted of four rounds with a focus on technical and behavioral assessments. Candidates faced a variety of coding questions related to data structures and algorithms in the first two rounds, followed by system design in the later stages. The interview overall was moderately challenging, requiring a solid understanding of data structures and conceptual knowledge in programming, especially JavaScript.

AI Powered

Share Your Story

Share your interview in your own words — our AI handles the rest. Hardly takes 2 minutes.

Take Mock Interview

Prepare better with expert feedback

Want to Connect 1:1?

Connect with me 1:1 for career guidance, resume reviews, interviews, and more.

Show Your Love!

Connect with us on social media

Best Time to Buy and Sell Stock | ServiceNow Interview Question | InterviewRecap | InterviewRecap