In c# because there was none
Intuition\nBased on heipit\'s solution a contribution in c# because there was none.\n\n# Code\n\npublic class Solution {\n    public int[] ClosestRoom(int[][] r
# Intuition\nBased on heipit\'s solution a contribution in c# because there was none.\n\n# Code\n```\npublic class Solution {\n    public int[] ClosestRoom(int[][] rooms, int[][] queries)\n    {\n        var indexes = new int[queries.Length];\n        for (int i = 0; i < queries.Length; i++) indexes[i] = i;\n\n        Array.Sort(rooms, (x, y) => y[1].CompareTo(x[1]));\n        Array.Sort(indexes, (x, y) => queries[y][1].CompareTo(queries[x][1]));\n\n        var answers = new int[queries.Length];\n        var roomIdsSoFar = new List<int>();\n        int roomIndex = 0;\n        foreach(int index in indexes)\n        {\n            while(roomIndex < rooms.Length && rooms[roomIndex][1] >= queries[index][1])\n            {\n                roomIdsSoFar.Add(rooms[roomIndex][0]);\n                roomIndex++;\n            }\n            roomIdsSoFar.Sort();\n\n            int floor = 0;\n            int ceil = int.MaxValue;\n            foreach (int id in roomIdsSoFar)\n            {\n                if (id <= queries[index][0] && id > floor) floor = id;\n                if (id > queries[index][0] && id < ceil) ceil = id;\n            }\n\n            int ansAbs = int.MaxValue, ans = -1;\n            if (floor > 0)\n            {\n                ans = floor;\n                ansAbs = Math.Abs(queries[index][0] - floor);\n            }\n            if (ceil < int.MaxValue && ansAbs > Math.Abs(queries[index][0] - ceil))\n            {\n                ans = ceil;\n            }\n\n            answers[index] = ans;\n        }\n        return answers;\n    }\n}\n```
['C#']