Pizza Delivery Guy Busted Eating Toppings Off a Customer's Pie
-
A pizza delivery guy in Saint Petersburg, Russia, was caught on an elevator
security cam selectively removing pizza toppings off a customer's pie with
hi...
12 minutes ago
Find the length of both the lists - say n1 and n2. Without any loss of generality, assume n1>=n2.
ReplyDeleteLet d=n1-n2.
Travel d nodes in List 1. And then start travelling each node one by one in both the lists until you reach the node on wich the lists merge.
Time complexity - O(n1+n2).
Can we do better than this?
no
ReplyDelete