From 177e6dd8fd2783d3ebb3fb394940de539ce7540a Mon Sep 17 00:00:00 2001 From: Vidhi006 <156179514+Vidhi006@users.noreply.github.com> Date: Thu, 30 Oct 2025 12:29:24 +0530 Subject: [PATCH 1/2] Create LongestCommonPrefix.java --- LongestCommonPrefix.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 LongestCommonPrefix.java diff --git a/LongestCommonPrefix.java b/LongestCommonPrefix.java new file mode 100644 index 000000000..5a3ca767a --- /dev/null +++ b/LongestCommonPrefix.java @@ -0,0 +1,18 @@ +class Solution { + public String longestCommonPrefix(String[] strs) { + int n = strs.length; + if(n == 0) return ""; + String prefix = strs[0]; + for(int i=1; i Date: Thu, 30 Oct 2025 12:32:14 +0530 Subject: [PATCH 2/2] Create longestCommonPrefix.java in this i am writing the code of longest common prefix by using string substring method --- longestCommonPrefix.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 longestCommonPrefix.java diff --git a/longestCommonPrefix.java b/longestCommonPrefix.java new file mode 100644 index 000000000..5a3ca767a --- /dev/null +++ b/longestCommonPrefix.java @@ -0,0 +1,18 @@ +class Solution { + public String longestCommonPrefix(String[] strs) { + int n = strs.length; + if(n == 0) return ""; + String prefix = strs[0]; + for(int i=1; i