dscmbcet / dscmbcet/hacktoberfest-2021

[java/Substring Search] Program always returning -1

Open
#70 0 comments 0 reactions 0 assignees View on GitHub
bug hacktober-fest Java medium
Dominant language
C
Stars
5
Forks
30
PR merge metrics
No merged PRs in 30d

Description

Q: Given two strings s1 and s2, find the index of the first occurrence of s2 in s1 as a substring. If no such occurrence exists, return -1.

**BUG**: For all inputs, only -1 is getting printed.

Case 1
Input : s1: `helloworld` s2: `low`
Ouput: `-1`
Expected: `3`

Case 2
Input : s1: `gdscmbcet` s2: `mbcet`
Ouput: `-1`
Expected: `4`

[Working directory](https://github.com/dscmbcet/hacktoberfest-2021/tree/main/Language/java/Substring%20Search)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.