#283. 字符串'bad'子串起始位置判断

    ID: 283 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-1gesp3字符串

字符串'bad'子串起始位置判断

Check for "bad" in String

Background

Congcong is currently learning about string manipulation. He encountered an interesting problem that requires determining if a specific substring appears at particular positions within a given string.

Problem Description

Given a string s, return true if the substring "bad" appears starting at index 0 or 1. For example, "badxxx" or "xbadxx" should return true, but "xxbadxx" should return false. The string s can be of any length, including 0. Note: use .equals() to compare two strings.

Input Format

Input is given from standard input in the following format.

s

Output Format

Output is printed to standard output in the following format.

result

Sample

badxx
true
xbadxx
true
xxbadxx
false

Sample Explanation

Sample 1: The string "badxx" contains "bad" starting at index 0, so it returns true. Sample 2: The string "xbadxx" contains "bad" starting at index 1, so it returns true. Sample 3: The string "xxbadxx" contains "bad" starting at index 2, which does not meet the condition of starting at index 0 or 1, so it returns false.

Constraints

Time limit: 1 second per test case. Memory limit: 1024 KiB per test case.