Gridland Metro

Sort by

recency

|

415 Discussions

|

  • + 0 comments

    test cases are not flushed out- i got away with writing bad code.

    test case needed:

    4 10 3 8 3 5 8 7 8 8 4 8

  • + 0 comments

    Is it expected that the C++ boilerplate does not parse the input integers correctly and that we have to debug that as well?

  • + 0 comments

    Branded merchandise tied to "Gridland Metro" is gaining attention as the game continues to captivate its players. Fans can find a range of collectible items, from stylish apparel to limited-edition accessories, all designed to enhance the connection with the unique gameplay experience. Whether you’re a strategy enthusiast or just discovering the game’s charm, these branded products offer a way to express your fandom and bring a piece of Gridland Metro into everyday life.

  • + 0 comments

    // where i am doing wrong

    public static long gridlandMetro(int n, int m, int k, List<List<Integer>> track) {
        Map<Integer,int[]> realPath = new HashMap<>();
        long result = 0;
        for(int i =0;i<k;i++){
            List<Integer> l1 = track.get(i);
            int row = l1.get(0);
            int c1 = l1.get(1);
            int c2 = l1.get(2);
            if(realPath.containsKey(row)){
                 int[] coloums = realPath.get(row);
                int c21 = coloums[0];
                int c22 = coloums[1];
                if(c21>c1){
                   coloums[0] = c1;
                }
                if(c22<c2){
                    coloums[1] = c2;
                }
                realPath.put(row, coloums);
            }else{
                int[] coloums = new int[2];
                coloums[0] = c1;
                coloums[1] = c2;
                realPath.put(row, coloums);
            }
        }
        for(int i =1;i<=n;i++){
            if(realPath.containsKey(i)){
                int[] coloums = realPath.get(i);
                int c21 = coloums[0];
                int c22 = coloums[1];
                int incr = (m+c21)-(c22+1);
                result+=incr;
            }else{
                result+=m;
            }
        }
        return result;
    }
    
  • + 1 comment
    long gridlandMetro(long n, long m, int k, vector<vector<int>> track) {
        if (track.empty()) return n * m;
        long lamppost = 0;
        sort(track.begin(), track.end());
        int currentRow = track[0][0], trackCell = 0, lastEnd = 0, rowCounter = 1;
        for (int i=0; i < track.size(); i++) {
            if (track[i][0] != currentRow) {
                lamppost = lamppost + m - trackCell;
                currentRow = track[i][0];
                trackCell = 0;
                lastEnd = 0;
                rowCounter++;
            }
            if (i < track.size()-1 and track[i+1][0] == currentRow and track[i][1] == track[i+1][1]) continue;
            trackCell = trackCell + track[i][2] - track[i][1] + 1;
            trackCell = (track[i][1] <= lastEnd) ? (trackCell - min(lastEnd-track[i][1]+1, track[i][2]-track[i][1]+1)) : trackCell;
            lastEnd = max(lastEnd, track[i][2]);
        }
        lamppost = lamppost + m - trackCell + m * (n - rowCounter);
        return lamppost;
    }
    

    O(n) except for the sort line