Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Problem B | Problems
Sorting Algorithms
course content

Зміст курсу

Sorting Algorithms

Sorting Algorithms

1. Simple Algorithms
2. Divide and Conquer Algorithms
3. Problems

Problem B

Завдання

Given two arrays arr1 and arr2, both consist of the same set of elements, but in arr1 they are distinct, meanwhile in arr2 are not. Sort the elements of arr2 such that the order of items in arr2 is the same as in arr1. All elements are non-negative.

Example 1

Input: arr1 = [3, 1, 2, 7, 5], arr2 = [2, 1, 1, 7, 3, 5, 7, 2, 1]

Output: [3, 1, 1, 1, 2, 2, 7, 7, 5]

Example 2

Input: arr1 = [0, 1, 3, 2], arr2 = [2, 0, 1, 3]

Output: [0, 1, 3, 2]

Завдання

Given two arrays arr1 and arr2, both consist of the same set of elements, but in arr1 they are distinct, meanwhile in arr2 are not. Sort the elements of arr2 such that the order of items in arr2 is the same as in arr1. All elements are non-negative.

Example 1

Input: arr1 = [3, 1, 2, 7, 5], arr2 = [2, 1, 1, 7, 3, 5, 7, 2, 1]

Output: [3, 1, 1, 1, 2, 2, 7, 7, 5]

Example 2

Input: arr1 = [0, 1, 3, 2], arr2 = [2, 0, 1, 3]

Output: [0, 1, 3, 2]

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 3. Розділ 2
toggle bottom row

Problem B

Завдання

Given two arrays arr1 and arr2, both consist of the same set of elements, but in arr1 they are distinct, meanwhile in arr2 are not. Sort the elements of arr2 such that the order of items in arr2 is the same as in arr1. All elements are non-negative.

Example 1

Input: arr1 = [3, 1, 2, 7, 5], arr2 = [2, 1, 1, 7, 3, 5, 7, 2, 1]

Output: [3, 1, 1, 1, 2, 2, 7, 7, 5]

Example 2

Input: arr1 = [0, 1, 3, 2], arr2 = [2, 0, 1, 3]

Output: [0, 1, 3, 2]

Завдання

Given two arrays arr1 and arr2, both consist of the same set of elements, but in arr1 they are distinct, meanwhile in arr2 are not. Sort the elements of arr2 such that the order of items in arr2 is the same as in arr1. All elements are non-negative.

Example 1

Input: arr1 = [3, 1, 2, 7, 5], arr2 = [2, 1, 1, 7, 3, 5, 7, 2, 1]

Output: [3, 1, 1, 1, 2, 2, 7, 7, 5]

Example 2

Input: arr1 = [0, 1, 3, 2], arr2 = [2, 0, 1, 3]

Output: [0, 1, 3, 2]

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 3. Розділ 2
toggle bottom row

Problem B

Завдання

Given two arrays arr1 and arr2, both consist of the same set of elements, but in arr1 they are distinct, meanwhile in arr2 are not. Sort the elements of arr2 such that the order of items in arr2 is the same as in arr1. All elements are non-negative.

Example 1

Input: arr1 = [3, 1, 2, 7, 5], arr2 = [2, 1, 1, 7, 3, 5, 7, 2, 1]

Output: [3, 1, 1, 1, 2, 2, 7, 7, 5]

Example 2

Input: arr1 = [0, 1, 3, 2], arr2 = [2, 0, 1, 3]

Output: [0, 1, 3, 2]

Завдання

Given two arrays arr1 and arr2, both consist of the same set of elements, but in arr1 they are distinct, meanwhile in arr2 are not. Sort the elements of arr2 such that the order of items in arr2 is the same as in arr1. All elements are non-negative.

Example 1

Input: arr1 = [3, 1, 2, 7, 5], arr2 = [2, 1, 1, 7, 3, 5, 7, 2, 1]

Output: [3, 1, 1, 1, 2, 2, 7, 7, 5]

Example 2

Input: arr1 = [0, 1, 3, 2], arr2 = [2, 0, 1, 3]

Output: [0, 1, 3, 2]

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Завдання

Given two arrays arr1 and arr2, both consist of the same set of elements, but in arr1 they are distinct, meanwhile in arr2 are not. Sort the elements of arr2 such that the order of items in arr2 is the same as in arr1. All elements are non-negative.

Example 1

Input: arr1 = [3, 1, 2, 7, 5], arr2 = [2, 1, 1, 7, 3, 5, 7, 2, 1]

Output: [3, 1, 1, 1, 2, 2, 7, 7, 5]

Example 2

Input: arr1 = [0, 1, 3, 2], arr2 = [2, 0, 1, 3]

Output: [0, 1, 3, 2]

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 2
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt