写点什么

ATRS Week 4

作者:Geek_c25301
  • 2023-09-09
    日本
  • 本文字数:1816 字

    阅读完需:约 6 分钟

Algorithm 一道算法题

这周的算法题是Profitable Schemes,大概知道是要用动态规划,但是看了半天还是没想出来应该怎么解。然后看了题解,实在是太巧妙了,这种题目还是要多做,多积累经验。


dp[p][g]表示的是对于不少于 p 的 profit,用 g 个 member 恰好能够达到的方法数。


所以如果 p + profit[i] < minProfit,那么 dp[p + profit[i]][g + group[i]] += dp[p][g]。如果 p + profit[i] >= minProfit,那么 dp[minProfit][g + group[i]] += dp[p][g]。


而且遍历的时候需要从后往前遍历,因为如果从前往后遍历,那么会被重复计算。


然后最后的结果就是 dp[minProfit][0] + dp[minProfit][1] + ... + dp[minProfit][n]。


class Solution {    public int profitableSchemes(int n, int minProfit, int[] group, int[] profit) {        int[][] dp = new int[minProfit + 1][n + 1];        int res = 0, mod = (int)1e9 + 7;        dp[0][0] = 1;
for (int k = 0; k < group.length; k++) { int g = group[k], p = profit[k];
for (int i = minProfit; i >= 0; i--) { for (int j = n - g; j >= 0; j--) { if (i + p < minProfit) { dp[i + p][j + g] = (dp[i + p][j + g] + dp[i][j]) % mod; } else { dp[minProfit][j + g] = (dp[minProfit][j + g] + dp[i][j]) % mod; } } } }
for (int x : dp[minProfit]) res = (res + x) % mod;
return res; }}
复制代码

Review 一篇英文文章

这周看的是和广告相关的一篇文章,7 Types of Automated Bidding Strategies & How to Use Them


Automated bidding aims to solve two concerns that advertisers often face their campaigns:


  • Whether or not their bids are high enough to compete for qualified buyers.

  • Whether or not their bids are too high and possibly showing to people who have no interest in making a purchase.


文章介绍了 7 种自动投标策略,每种策略都有其适用的场景,需要根据实际情况来选择。

Technique/Tips 一个技术点

关于 eventhub 与 service bus 的区别,我比较关注的几点是:


  1. Message format

  2. Azure Service Bus: Service Bus supports structured message formats like JSON and XML, making it well-suited for application-to-application communication where message content is predefined and known in advance.

  3. Azure Event Hubs: Event Hubs deals with raw event data and supports unstructured data in various formats. It's common to send events in binary or Avro format, which allows flexibility in processing the data on the consumer side

  4. Message Ordering:

  5. Azure Service Bus: Service Bus guarantees strict message ordering within a partition or queue, ensuring that messages are processed in the order they are received.

  6. Azure Event Hubs: Event Hubs provides at-least-once event delivery but does not guarantee strict ordering of events. It focuses on high throughput and low latency, allowing events to be processed out of order if necessary.

  7. Retention and Capture:

  8. Azure Service Bus: Service Bus has a shorter retention period for messages (default is 7 days) and does not support automatic capture of message data.

  9. Azure Event Hubs: Event Hubs has a longer retention period (default is 7 days, extendable up to 90 days) and supports automatic capture of events to Azure Blob Storage for long-term storage and analysis.


总而言之,当需要可靠的消息传递用于应用程序集成和通信时,请选择 Azure service bus。当需要一个高吞吐量事件流平台来 ingesting、processing 和 analyzing 大量事件数据时,请选择 Azure event hubs。两者之间的选择取决于特定用例和消息传递需求。

Share 一个观点

和别人讨论技术方案的时候,有什么不理解或者不赞成的地方,一定要说出来,不要因为别人的技术水平比你高或者比较强硬就不敢说话,这样只会让自己越来越被动,最后可能会导致项目失败。然后有时候在会议上没法达成一致的,也可以线下在进行讨论,最后达成一致。

用户头像

Geek_c25301

关注

还未添加个人签名 2022-03-19 加入

还未添加个人简介

评论

发布
暂无评论
ATRS Week 4_Geek_c25301_InfoQ写作社区