头条编程题用户喜好值有100%AC的吗?
我付一个JS的暴力代码吧,只能过50%:
var n = Number(readline()); var arr = readline().split(" ")); var q = Number(readline()); var line; while(line = readline()){ line = line.split(" ").map(function(elem, index) { return Number(elem); }); var l = line[0]; var r = line[1]; var k = line[2]; var num = 0; for (var i = l-1; i < r; i++){ if(arr[i] == k){ num++; } } print(num); }
请问有100%的同学吗?能讲些写思路吗?谢谢咯