Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Count Characters

Easy Acceptance 85% Points 20

You are given a string s. Your task is to count the total number of characters in the string.

Return the count.

Examples
Example 1

Example 1

Input: s = "hello"

Output: 5

Explanation: The string contains 5 characters.

Example 2

Example 2

Input: s = "abcd"

Output: 4

Explanation: There are 4 characters in the string.

Example 3

Example 3

Input: s = "a"

Output: 1

Explanation: The string has only one character.

Constraints
  • 1 = length of s = 105
  • The string contains printable characters only
Topics
Recursion
Companies
Microsoft Apple Mastercard
Added 19 Jul 2026 85% acceptance
Ln 1, Col 1Sign in to save your code
hello
5