The same problem from https://leetcode.com/discuss/interview-question/871750/yelp-oa

image

class PositiveReview {
	Integer userId;
	Integer businessId;

	public PositiveReview(Integer userId, Integer businessId) {
		this.userId = userId;
		this.businessId = businessId;
	}

	public Integer getUserId() {
		return this.userId;
	}
	public Integer getBusinessId() {
		return this.businessId;
	}
}
class Solution {


//	Sample Input
//	{
//	"businessOfInterestId": 10,
//	"positiveReviews": [
//	PositiveReview(
//	"userId": 1,
//	"businessId": 10
//	),
//	PositiveReview(
//	"userId": 2,
//	"businessId": 10
//	),
//	PositiveReview(
//	"userId": 1,
//	"businessId": 11
//	),
//	PositiveReview(
//	"userId": 2,
//	"businessId": 11
//	),
//	PositiveReview(
//	"userId": 1,
//	"businessId": 12
//	),
//	PositiveReview(
//	"userId": 2,
//	"businessId": 12
//	),
//	PositiveReview(
//	"userId": 3,
//	"businessId": 12
//	)
//	]
//	}

//	Sample Output
//		11

//	Business Similarity Score against business 10:
//		11: 2 / (2 + 2 - 2) = 1.0
//		12: 2 / (2 + 3 - 2) = 0.667
//
	public static Integer findMostSimilarBusiness(
		Integer businessOfInterestId,
		List<PositiveReview> positiveReviews
	) {

	}

	public static void main(String[] args) {

	}

Can somebody give me a Java solution? I didn't pass all tests.

Comments (2)