---
title: "Discussion on \"LeetCode  28. Find the Index of the First Occurrence in a String\" | Hashnode"
description: "Discussion on \"LeetCode  28. Find the Index of the First Occurrence in a String\". Question Statement: Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.  \nExample 1: Input: haystack = \"sadbutsad\", needle = \"sad\" Output: 0 Explanation: \"sad..."
url: "https://hashnode.com/posts/leetcode-28-find-the-index-of-the-first-occurrence-in-a-string/64e78431fe0b1ce8b324b072"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [LeetCode 28. Find the Index of the First Occurrence in a String](https://pranjitmedhi.hashnode.dev/leetcode-28-find-the-index-of-the-first-occurrence-in-a-string?utm_source=hashnode&utm_medium=feed)

Question Statement: Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = "sadbutsad", needle = "sad" Output: 0 Explanation: "sad...

Aug 24, 2023 · 1 min read · pranjitmedhi.hashnode.dev  
Read the article

-   [#leetcode](https://hashnode.com/tag/leetcode)
-   [#substring](https://hashnode.com/tag/substring)

## Written by

[Pranjit Medhi](https://hashnode.com/@Pranjit)

@Pranjit

  
[View profile](https://hashnode.com/@Pranjit)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
