From 2377f0097b7e5973ad7ffb84e139bbfca206cd40 Mon Sep 17 00:00:00 2001 From: shrey38 <62564421+shrey38@users.noreply.github.com> Date: Thu, 14 Jul 2022 20:15:13 +0530 Subject: [PATCH] Update Counting Triangle.java --- Two Pointers/Counting Triangle.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Two Pointers/Counting Triangle.java b/Two Pointers/Counting Triangle.java index 2a0f7db..9f0edad 100644 --- a/Two Pointers/Counting Triangle.java +++ b/Two Pointers/Counting Triangle.java @@ -6,13 +6,13 @@ public int nTriang(ArrayList A) { int mod = 1000000007; Collections.sort(A); - for(int i=n-1; i>=0; i--) { + for(int i=n-1; i>1; i--) { int j = 0; int k = i-1; while (j A.get(i)) { - res = (res + (k-j)%mod)%mod; + res = (res + (k-j))%mod; k--; } else {