Google | Phone interview | waiting
Anonymous User
1459

Create a class below these two method. I am able to find the solution using TreeMap and update the range with the final Time complexity is O(n^2). Is there any better solution? Love to learn from my mistake.

class Solution{
	void addRange(int x , int y);
	boolean isPresent(int v);
	}
    addRange(5,10)
	addRange(13,14)
	isPresent(3) -> false
	isPresent(5) -> true
	isPresent(14) -> true
	addRange(10,19)
	isPresent(16) -> true
	isPresent(19) -> true
	isPresent(3) -> false
Comments (7)