HTML & JS
#include <stdio.h>
#include <stdlib.h>
/* edges in graph */

int main() {
    int n, t1, t2, k, v;
    scanf("%d\n", &n); // no. of edges
    int edges[n][2];
    v = 2*n+1; // no. of vertices can't be more than twice of edges
    int *degree = (int *)calloc(v, sizeof(int)); // stores degree of vertices initialized to 0
	for(int i = 0; i < n; ++i) {
	    scanf("%d %d", &t1, &t2);
	    edges[i][0] = t1;
	    edges[i][1] = t2;
	    degree[t1]++; // degree is incremented for both vertices
	    degree[t2]++;
	}
	scanf("%d", &k); // degree
	for(int i = 0; i < v; ++i) {
	    if(degree[i] >= k) {
	        for(int j = 0; j < n; j++) {
	            if(edges[j][0] == i || edges[j][1] == i) n--; // no. of edges are decremented
	        }
	    }
	}
	printf("%d", n);
	return 0;
}

Generated URL:

Output:

2
Report Bug