Skip to content

Repository files navigation

Welcome

LIST Indexing

Automated grading of homework assignments and tests

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

Problems

List01

You will be given a list of fruits. Add x fruit to it from the end and return.

Example 1:

Input: fruits = ["apple", "banana"] x = 'kiwi'
Output: ["apple", "banana", "kiwi"]

Constraints:

  • 1 <= length(fruits) <= 10^5

List02

You will be given a list of fruits. Add the x fruit to the i index and return it.

Example 1:

Input: fruits = ["apple", "banana"] x = 'kiwi' i=1
Output: ["apple", "kiwi", "banana"]

Constraints:

  • 1 <= length(fruits) <= 10^5
  • 0 <= i < length(fruits)

List03

You will be given a list of several fruits called fruits1 and fruits2. Return the result by adding the second to the first list.

Example 1:

Input: fruits1 = ["apple", "banana"] fruits2 = ["kiwi", "pear"]
Output: ["apple", "banana", "kiwi", "pear"]

Constraints:

  • 1 <= length(fruits1) <= 10^5
  • 1 <= length(fruits2) <= 10^5

List04

You are given a list of numbers. i Delete and return the number in the index.

Example 1:

Input: numbers = [1, 2, 3, 4, 5] i = 2
Output: 3

Example 2:

Input: numbers = [4, 7, 3, 2, 8] i = 4
Output: 8

Constraints:

  • 1 <= length(numbers) <= 10^5
  • 0 <= i < length(numbers)

List05

You are given a list called numbers1 and numbers2. Delete the last item in the first list and add that deleted item to the beginning of the second list. Merge the first list into the second and return.

Example 1:

Input: numbers1 = [6, 8, 1] numbers2 = [3, 5, 7]
Output: [6, 8, 1, 3, 5, 7]

Constraints:

  • 1 <= length(numbers1) <= 10^5
  • 1 <= length(numbers2) <= 10^5

List06

Given a list called Fruits, it contains at least one apple. Find how many apples are on the list and return.

Example 1:

Input: fruits = ["apple", "banana", "apple", "pear"]
Output: 2

Example 2:

Input: fruits = ["apple", "banana", "apple", "apple", "apple]
Output: 4

Constraints:

  • 1 <= length(fruits) <= 10^5

List07

A list of zeros and ones is given. Find how many zeros are involved and return.

Example 1:

Input: list1 = [1, 0, 1, 1, 0, 1, 1]
Output: 2

Example 2:

Input: fruits = [0, 0, 0, 0, 0, 0, 0]
Output: 7

Constraints:

  • 1 <= length(list1) <= 10^5

List08

A list called "fruits" is given and is five in length and contains at least one "apple". Remove the apples from the list and return the list.

Example 1:

Input: fruits = ["apple", "banana", "apple", "pear", "apple"]
Output: ["banana", "pear"]

Example 2:

Input: fruits = ["apple", "apple", "apple", "apple", "kiwi"]
Output: ["kiwi"]

Constraints:

  • length(fruits) == 5

List09

A list called “fruits” is given and is five in length and contains at least one “apple”. Calculate how many “apple” were involved and return the indexes in a list view.

Example 1:

Input: fruits = ["apple", "banana", "apple", "pear", "apple"]
Output: [3, 0, 2, 4]

Example 2:

Input: fruits = ["apple", "apple", "apple", "apple", "kiwi"]
Output: [4, 0, 1, 2, 3]

Constraints:

  • length(fruits) == 5

List10

A list of zeros and ones is given. Find how many ones and how many zeros there are and return to the list form.

Example 1:

Input: list1 = [1, 0, 0, 0, 1, 0, 1, 0]
Output: [3, 5]

Example 2:

Input: list1 = [0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1]
Output: [4, 7]

Constraints:

  • 1 <= length(list1) <= 10^5

Warning

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages