All you have to do is resolve the velocity into x and y components. Now, since you have to determine the height of the window, only y component of velocity of the bag will affect its vertical motion. Also, it just reaches the window which could only happen if its vertical component of final velocity becomes zero. All you have to do is, use kinematic equation,
v^2 - u^2 = 2gh
v= final velocity(vertical component) = 0 m/s u = initial velocity (vertical component) g = acceleration due to gravity h = height of the window from the ground