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

Course Content

Sorting Algorithms

Sorting Algorithms

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

Problem D

Task

Given an integer array nums of possible sides lengths. Return the largest perimeter of the triangle that can be reached by combining these lengths. If there is no such a perimeter, return 0.

Example 1

Input: nums = [6, 3, 2, 3, 1, 9, 7]

Output: 22. Use lengths 6, 7 and 9.

Example 2

Input: nums = [4, 1, 5, 9]

Output: 0. There is no possible triangle, you can't use 4, 5, and 9, for example.

Example 3

Input: nums = [7, 15, 7, 7, 6]

Output: 21. Use 7, 7, 7.

Task

Given an integer array nums of possible sides lengths. Return the largest perimeter of the triangle that can be reached by combining these lengths. If there is no such a perimeter, return 0.

Example 1

Input: nums = [6, 3, 2, 3, 1, 9, 7]

Output: 22. Use lengths 6, 7 and 9.

Example 2

Input: nums = [4, 1, 5, 9]

Output: 0. There is no possible triangle, you can't use 4, 5, and 9, for example.

Example 3

Input: nums = [7, 15, 7, 7, 6]

Output: 21. Use 7, 7, 7.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 3. Chapter 4
toggle bottom row

Problem D

Task

Given an integer array nums of possible sides lengths. Return the largest perimeter of the triangle that can be reached by combining these lengths. If there is no such a perimeter, return 0.

Example 1

Input: nums = [6, 3, 2, 3, 1, 9, 7]

Output: 22. Use lengths 6, 7 and 9.

Example 2

Input: nums = [4, 1, 5, 9]

Output: 0. There is no possible triangle, you can't use 4, 5, and 9, for example.

Example 3

Input: nums = [7, 15, 7, 7, 6]

Output: 21. Use 7, 7, 7.

Task

Given an integer array nums of possible sides lengths. Return the largest perimeter of the triangle that can be reached by combining these lengths. If there is no such a perimeter, return 0.

Example 1

Input: nums = [6, 3, 2, 3, 1, 9, 7]

Output: 22. Use lengths 6, 7 and 9.

Example 2

Input: nums = [4, 1, 5, 9]

Output: 0. There is no possible triangle, you can't use 4, 5, and 9, for example.

Example 3

Input: nums = [7, 15, 7, 7, 6]

Output: 21. Use 7, 7, 7.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 3. Chapter 4
toggle bottom row

Problem D

Task

Given an integer array nums of possible sides lengths. Return the largest perimeter of the triangle that can be reached by combining these lengths. If there is no such a perimeter, return 0.

Example 1

Input: nums = [6, 3, 2, 3, 1, 9, 7]

Output: 22. Use lengths 6, 7 and 9.

Example 2

Input: nums = [4, 1, 5, 9]

Output: 0. There is no possible triangle, you can't use 4, 5, and 9, for example.

Example 3

Input: nums = [7, 15, 7, 7, 6]

Output: 21. Use 7, 7, 7.

Task

Given an integer array nums of possible sides lengths. Return the largest perimeter of the triangle that can be reached by combining these lengths. If there is no such a perimeter, return 0.

Example 1

Input: nums = [6, 3, 2, 3, 1, 9, 7]

Output: 22. Use lengths 6, 7 and 9.

Example 2

Input: nums = [4, 1, 5, 9]

Output: 0. There is no possible triangle, you can't use 4, 5, and 9, for example.

Example 3

Input: nums = [7, 15, 7, 7, 6]

Output: 21. Use 7, 7, 7.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Task

Given an integer array nums of possible sides lengths. Return the largest perimeter of the triangle that can be reached by combining these lengths. If there is no such a perimeter, return 0.

Example 1

Input: nums = [6, 3, 2, 3, 1, 9, 7]

Output: 22. Use lengths 6, 7 and 9.

Example 2

Input: nums = [4, 1, 5, 9]

Output: 0. There is no possible triangle, you can't use 4, 5, and 9, for example.

Example 3

Input: nums = [7, 15, 7, 7, 6]

Output: 21. Use 7, 7, 7.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 3. Chapter 4
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt