博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HackerRank - A super hero !!
阅读量:5462 次
发布时间:2019-06-16

本文共 941 字,大约阅读时间需要 3 分钟。

Nice problem that can help you understand 2 key skills below:

- How to choose between Greedy and DP

Is the local optimal the ONLY option? Can other choices(computation pathes) contribute to current optimal value choise?

Considering this problem: on level i, can we simply pick the one with min Power? not really - because there's another factor to involve: Bullet #, that means, the one with min Power may not give you enough Bullet and then contribute to an optimal in future levels - So Greedy won't work. Then DP is the natural choice.

- DP optimization

This is step 2. When you write down the inital DP equation, give it another observation. In the inner-est loop, what you are trying to find out, is some minimal from the previous level - so, here we use Greedy by Sorting!

I enjoyed this problem a lot, which is marked as HARD on HackerRank. I assume HARD means, >1 key tricks combined.

 

转载于:https://www.cnblogs.com/tonix/p/7902783.html

你可能感兴趣的文章
ASP.NET MVC 3 新特性
查看>>
vue报错信息
查看>>
布林带
查看>>
数据平滑
查看>>
奇异值分解
查看>>
快速傅里叶变换模块(fft)
查看>>
随机数模块(random)
查看>>
杂项功能(排序/插值/图像/金融相关)
查看>>
pandas核心
查看>>
线性回归
查看>>
机器学习学习索引
查看>>
多项式回归
查看>>
Python-字符串
查看>>
MySQL8.0安装以及介绍(二进制)
查看>>
MySQL权限系统
查看>>
Python-集合
查看>>
转:标签中的href如何调用js
查看>>
CrawlSpiders简介
查看>>
面向对象编程
查看>>
django-rest-framework 视图的使用规则 总结分享
查看>>