C# solution - all test cases passed but took too long to execute?! Java version gets accepted
I can\'t figure out what\'s wrong with my solution so I would appreacite if anyone can look into it. It passes all test casses but I get "41 / 41 test cases pas
I can\'t figure out what\'s wrong with my solution so I would appreacite if anyone can look into it. It passes all test casses but I get **"41 / 41 test cases passed, but took too long."** Thanks.\n```\npublic class Solution {\n    public int[] ClosestRoom(int[][] rooms, int[][] queries) {\n        Array.Sort(rooms, (item1, item2) => item1[1].CompareTo(item2[1]));\n        var result = new int[queries.Length];\n        var resultIndex = 0;\n        \n        foreach(var query in queries)\n        {\n            var minDifference = int.MaxValue;\n            var minId = int.MaxValue;\n            \n            var roomSizeStartIndex = GetStartIndexForRoomSize(query[1], rooms);\n            \n            if(roomSizeStartIndex != -1)\n            {\n                for(int i = roomSizeStartIndex; i < rooms.Length; i++)\n                {\n                    var room = rooms[i];\n\n                    if(room[1] >= query[1])\n                    {\n                        var roomIdDifference = Math.Abs(query[0] - room[0]);\n\n                        if(roomIdDifference < minDifference || (roomIdDifference == minDifference && room[0] < minId))\n                        {\n                            minDifference = roomIdDifference;\n                            minId = room[0];\n                        }\n                    }\n                }\n            }\n            \n            if(minDifference == int.MaxValue)\n                minId = -1;\n            \n            result[resultIndex++] = minId;\n        }\n        \n        return result;\n    }\n    \n    private int GetStartIndexForRoomSize(int targetSize, int[][] rooms)\n    {\n        var left = 0;\n        var right = rooms.Length - 1;\n        var startIndex = -1;\n        \n        while(left <= right)\n        {\n            var mid = left + (right - left) / 2;\n            \n            if(rooms[mid][1] >= targetSize)\n            {\n                right = mid - 1;\n                startIndex = mid;\n            }\n            else\n                left = mid + 1;\n        }\n        \n        return startIndex;\n    }\n}\n```
[]