From ea9cdff1e5f97f283d5a086c5fd054ced478c187 Mon Sep 17 00:00:00 2001 From: Tanmay-312 Date: Thu, 15 Feb 2024 16:01:58 +0530 Subject: [PATCH] Added codes for 15 Feb --- GeeksForGeeks/February/15-2-24/GFG.java | 57 ++++++++++++++++++++++++ GeeksForGeeks/February/15-2-24/README.md | 2 + LeetCode/February/15-2-24/README.md | 2 + LeetCode/February/15-2-24/Solution.java | 18 ++++++++ 4 files changed, 79 insertions(+) create mode 100644 GeeksForGeeks/February/15-2-24/GFG.java create mode 100644 GeeksForGeeks/February/15-2-24/README.md create mode 100644 LeetCode/February/15-2-24/README.md create mode 100644 LeetCode/February/15-2-24/Solution.java diff --git a/GeeksForGeeks/February/15-2-24/GFG.java b/GeeksForGeeks/February/15-2-24/GFG.java new file mode 100644 index 0000000..3ece1b1 --- /dev/null +++ b/GeeksForGeeks/February/15-2-24/GFG.java @@ -0,0 +1,57 @@ +//{ 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().trim()); + while(T-->0) + { + int n = Integer.parseInt(br.readLine().trim()); + int[][] paths = new int[n][n]; + for(int i = 0; i < n; i++){ + String[] s = br.readLine().trim().split(" "); + for(int j = 0; j < n; j++){ + paths[i][j] = Integer.parseInt(s[j]); + } + } + Solution obj = new Solution(); + int ans = obj.isPossible(paths); + System.out.println(ans); + + } + } +} + +// } Driver Code Ends + + +//User function Template for Java + +class Solution +{ + public int isPossible(int[][] paths) + { + // Code here + for(int i=0;i= 2; --i) + { + prefix -= nums[i]; + if (prefix > nums[i]) + return prefix + nums[i]; + } + + return -1; + } +}