Welcome

String Indexing

Automated grading of homework assignments and tests

  • fork this repository
  • solve the task
  • commit with proper message

Problems

Index01

The string variable s is given. return the first character.

Example 1:

Input: a="python"
Output: "p"

Example 2:

Input: a="code"
Output: "c"

Constraints:

  • 2 <= length(a) <= 10^5

Index02

The string variable s is given. return the second character.

Example 1:

Input: a="python"
Output: "y"

Example 2:

Input: a="code"
Output: "y"

Constraints:

  • 2 <= length(a) <= 10^5

Index03

The string variable s is given. return the last character.

Example 1:

Input: a="number"
Output: "r"

Example 2:

Input: a="code"
Output: "e"

Constraints:

  • 2 <= length(a) <= 10^5

Index04

The s string variable is given. Return three characters from the beginning.

Example 1:

Input: a="number"
Output: "num"

Example 2:

Input: a="codeschool"
Output: "cod"

Constraints:

  • 4 <= length(a) <= 10^5

Index05

Given a variable s string of length five. Determine the number of digits involved in this variable.

Example 1:

Input: a="32x3z"
Output: 3

Example 2:

Input: a="12340"
Output: 5

Constraints:

  • length(a) == 5

Index06

A string variable consisting of several characters is given. Add and return the first and last character.

Example 1:

Input: a="uz"
Output: "uz"

Example 2:

Input: a="good"
Output: "gd"

Constraints:

  • 2 <= length(a) <= 10^5

Index07

The s string variable is given. n Return the character in the index, otherwise return False.

Example 1:

Input: a="uz" n=4
Output: False

Example 2:

Input: a="good" n=3
Output: "d"

Constraints:

  • 2 <= length(a) <= 10^5

Index08

A string of length five is given. Return the index of the "*" character, return False if not present.

Example 1:

Input: a="2*44"
Output: 1

Example 2:

Input: a="good"
Output: False

Constraints:

  • 2 <= length(a) <= 10^5

Index09

a single character string is given. Convert it to int type, return -1 if not possible.

Example 1:

Input: a="4"
Output: 4

Example 2:

Input: a="k"
Output: -1

Constraints:

  • length(a) == 1

Index10

A string of five numbers is given. Find the sum of its numbers.

Example 1:

Input: a="12332"
Output: 11

Example 2:

Input: a="10002"
Output: 3

Constraints:

  • length(a) == 5

Warning

  • don't copy other solutions or any solution
  • don't remove comments