Загрузка страницы

LeetCode 312. Burst Balloons[ Algorithm + Code Explained]

One of the most frequently asked coding interview questions on Arrays in companies like Google, Facebook, Amazon, LinkedIn, Microsoft, Uber, Apple, Adobe etc.

LeetCode : Burst Balloons

Problem URL - https://leetcode.com/problems/burst-balloons/


Question :Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[left] * nums[i] * nums[right] coins. Here left and right are adjacent indices of i. After the burst, the left and right then becomes adjacent.

Find the maximum coins you can collect by bursting the balloons wisely.

Note:

You may imagine nums[-1] = nums[n] = 1. They are not real therefore you can not burst them.
0 gt n lt 500,
0 gt nums[i] lt 100

Input: [3,1,5,8]
Output: 167
Explanation: nums = [3,1,5,8] -- [3,5,8] -- [3,8] -- [8] -- []
coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167

Connect with me on LinkedIn at: https://www.linkedin.com/in/jayati-tiwari/

Видео LeetCode 312. Burst Balloons[ Algorithm + Code Explained] канала jayati tiwari
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
18 мая 2020 г. 15:15:11
00:18:31
Яндекс.Метрика