Skip to content
Programmingoneonone
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

Learn everything about programming

HackerEarth Friendless Dr. Sheldon Cooper problem solution

YASH PAL, 31 July 2024
In this HackerEarth Friendless Dr. Sheldon Cooper problem solution Leonard has decided to quit living with Dr. Sheldon Cooper and has started to live with Penny. Yes, you read it right. (And you read it here for the first time!) He is fed up of Sheldon, after all. Since, Sheldon no more has Leonard to drive him all around the city for various things, he’s feeling a lot uneasy so he decides to set up a network of drivers all around the city to drive him to various places.
But, not every driver wants to go every place in the city for various personal reasons, so Sheldon needs to trust many different cab drivers. (Which is a very serious issue for him, by the way!) The problem occurs mainly when Sheldon needs to go to – for example, the Comic book store – and there’s no cab driver who goes directly to that place. So, he has to take a cab till another place, and then take a cab from there – making him more scared!
Sheldon wants to limit his trust issues. Really. Once. And. For. All.
Let’s say that you’re given the schedule of all the cabs from the major points where he travels to and from – can you help Sheldon figure out the least number of cab drivers he needs to trust, in order to go to all the places he wants to?
HackerEarth Friendless Dr. Sheldon Cooper problem solution

HackerEarth Friendless Dr. Sheldon Cooper problem solution.

tc = int(raw_input())
while (tc>0):
tc = tc - 1
a, b = map(int, raw_input().split())
while (b>0):
b = b - 1
m, n = map(int, raw_input().split())
print a-1

Second solution

for _ in xrange(input()):
a,b=map(int,raw_input().split())
for __ in xrange(b):
raw_input()
print a-1
coding problems solutions

Post navigation

Previous post
Next post

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes