From ef9cb6a133ac41aa5b05613f90cb38ad3fcb699d Mon Sep 17 00:00:00 2001 From: Ben Makusha Date: Mon, 6 Mar 2023 22:45:57 -0500 Subject: [PATCH 1/2] Create 0028-find-the-index-of-the-first-occurence-in-a-string --- ...e-index-of-the-first-occurrence-in-a-string.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 java/0028-find-the-index-of-the-first-occurrence-in-a-string.java diff --git a/java/0028-find-the-index-of-the-first-occurrence-in-a-string.java b/java/0028-find-the-index-of-the-first-occurrence-in-a-string.java new file mode 100644 index 000000000..04868dc8e --- /dev/null +++ b/java/0028-find-the-index-of-the-first-occurrence-in-a-string.java @@ -0,0 +1,13 @@ +class Solution { + public int strStr(String haystack, String needle) { + int result = 0; + if (haystack.length() <= 0 && needle.length() > 0) return -1; + if (haystack.length() != 0) { + int occurence = haystack.indexOf(needle); + if (occurence == -1) + return occurence; + result = occurence; + } + return result; + } +} \ No newline at end of file From 03da7f39ec64f980c3d6a7684f5fc37aa69c1a08 Mon Sep 17 00:00:00 2001 From: Ben Makusha Date: Wed, 8 Mar 2023 23:30:55 -0500 Subject: [PATCH 2/2] Update java/0028-find-the-index-of-the-first-occurrence-in-a-string.java --- ...0028-find-the-index-of-the-first-occurrence-in-a-string.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/0028-find-the-index-of-the-first-occurrence-in-a-string.java b/java/0028-find-the-index-of-the-first-occurrence-in-a-string.java index 04868dc8e..181bf5ca1 100644 --- a/java/0028-find-the-index-of-the-first-occurrence-in-a-string.java +++ b/java/0028-find-the-index-of-the-first-occurrence-in-a-string.java @@ -10,4 +10,4 @@ public int strStr(String haystack, String needle) { } return result; } -} \ No newline at end of file +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy