It all started on a train to Bengaluru a little over six years ago. Harishankaran (Hari) Karunanidhi and Vivek Ravisankar, college friends and co-founders of InterviewStreet, a company that conducted mock interviews for engineering students, were arguing prices. They had created an online coding test for companies to use during campus recruitment, and were going to pitch it to Vijay Ramachandran, founder of search firm WisdomTap. “We wanted to price it at a point where companies wouldn’t have to think twice, so we thought of starting at Rs 5 per candidate,” recalls Hari.

But perhaps companies could afford more; were they underpricing the test? They reached Bengaluru having discussed options ranging from Rs 5 per candidate to Rs 50. They finally agreed to leave the price to their prospective customer. How much would Ramachandran pay for the test? He said Rs 100 seemed fair, since an online test would save the company up to an hour per candidate. “We told him: Use this for free, but mail everyone in your contact list about the test,” says Hari. On Ramachandran’s mailing list was an ex-colleague, Mekin Maheshwari, then head of engineering at Flipkart. Maheshwari called the same day asking for a demo. “We cancelled our return tickets. It was Flipkart after all,” says Hari.

Two months later, the Flipkart team was at IIT Madras to recruit—this time with Hari and the online test. The results were out in 15 minutes compared to 4 hours when the tests were written by hand. The company soon got other paying customers, including and Amazon, and then, Facebook. “Facebook came to us with a specific requirement of testing people on their language skill. We tailored the test module and they still use it as the only automated platform for testing language skills there.”

Interestingly, the two founders hadn’t thought of a business around online test modules. Both techies from NIT Trichy, they had left their jobs at IBM and Amazon to set up InterviewStreet. “Most engineering students in India aren’t trained to sit through interviews,” says Hari. As InterviewStreet, the two put together a team of recruiters to conduct interviews. Students would pay Rs 1,000 per session; the recruiter would get Rs 600, InterviewStreet the rest.

The idea bombed. After almost a year and a half, InterviewStreet had made a grand total of Rs 4,000. “We knew we were going wrong, but we couldn’t figure where. There seemed to be a problem in execution but we didn’t want to give up because what if someone else came along and did this?” says Hari. Persistence paid off. One of the students who took a session, asked for an online test he could practice on. Hari and Ravishankar created a test for the student, who paid Rs 1,000 for it. Perhaps this was the big idea, they thought. As indeed it was.

With clients such as Facebook and Amazon, the duo applied to Y Combinator, one of the world’s most influential startup incubators. Previous applications had been rejected. Persistence, clearly, is something this pair is good at. This time, they were selected, and invited to Silicon Valley for three months of fine-tuning their business idea before pitching it to investors. The duo set out, hoping to get at least 50 customers in the U.S. during this exercise, even if they did not get funding.

During the three-month stint, they met Paul Graham, one of the co-founders of Y Combinator, who offered advice that was the genesis of HackerRank, the community of programmers. Graham’s take: You’re solving the assessment problem for companies, but sourcing is the bigger issue. If you can find the top 10 programmers on your own, your product would be much more valuable. If someone could kill your company, that’s what they would be doing. You should build that company.

Hari and Ravisankar did just that, and got funding from a handful of investors, including the legendary Vinod Khosla. Since then, HackerRank has completed a Series B round and a strategic investment.

They created CodeSprint, a coding contest that anyone could take. “The idea was to democratise programming,” says Hari.

Today, HackerRank has a community of 1.5 million programmers, ranked by their performance across programming languages.

The latest solution is HackerRank Jobs, a platform where programmers can look at openings and take tests for that specific role. If they clear the cut off, their tests scores are sent to that company along with the résumés.

Follow us on Facebook, Twitter, YouTube & Instagram to never miss an update from Fortune India. To buy a copy, visit Amazon.