From c08108f1322f93be74d30ac0215d910d1fc29e80 Mon Sep 17 00:00:00 2001 From: Tanmay-312 Date: Thu, 18 Apr 2024 18:19:39 +0530 Subject: [PATCH] Added codes for 18 April --- GeeksForGeeks/April/18-4-24/GFG.java | 62 +++++++++++++++++++++++++++ GeeksForGeeks/April/18-4-24/README.md | 2 + LeetCode/April/18-4-24/README.md | 2 + LeetCode/April/18-4-24/Solution.java | 25 +++++++++++ 4 files changed, 91 insertions(+) create mode 100644 GeeksForGeeks/April/18-4-24/GFG.java create mode 100644 GeeksForGeeks/April/18-4-24/README.md create mode 100644 LeetCode/April/18-4-24/README.md create mode 100644 LeetCode/April/18-4-24/Solution.java diff --git a/GeeksForGeeks/April/18-4-24/GFG.java b/GeeksForGeeks/April/18-4-24/GFG.java new file mode 100644 index 0000000..9ff9fd6 --- /dev/null +++ b/GeeksForGeeks/April/18-4-24/GFG.java @@ -0,0 +1,62 @@ +//{ Driver Code Starts +//Initial template for JAVA + +import java.util.*; +import java.lang.*; +import java.io.*; + +class GFG + { + public static void main (String[] args) throws IOException + { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int t = Integer.parseInt(br.readLine()); + for(int i=0;i set = new HashSet<>(); + + int[] ans = new int[2]; + int j=0; + for(int i=0;i= 0 && grid[i - 1][j] == 1) + ++neighbors; + if (j - 1 >= 0 && grid[i][j - 1] == 1) + ++neighbors; + } + } + } + + return islands * 4 - neighbors * 2; + } +}