Page MenuHomedesp's stash

Solution.java
No OneTemporary

Solution.java

public class Solution {
public static int solution(int[] l) {
int count = 0;
for(int i = 0; i < l.length; i++) {
for(int j = i + 1; j < l.length; j++) { //since index i < j search onwards for the second number
if(l[j] % l[i] == 0) { //if second number is divisible move on the finding the third
for(int k = j + 1; k < l.length; k++) { //same logic as loop above for the third number
if(l[k] % l[j] == 0) count++; //found a tuple since third is divisible by second
}
}
}
}
return count;
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, May 11, 1:14 PM (1 d, 15 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d3/6b/1c5dd9473e8805a36b5ba878b236

Event Timeline