Ethan's Blog


  • Home

  • Archives

  • Tags

  • Search

最易懂的贪心算法

Posted on 2022-07-11

算法解释

顾名思义,贪心算法或贪心思想采用贪心的策略,保证每次操作都是局部最优的,从而使最后得到的结果是全局最优的。

举一个最简单的例子:小明和小王喜欢吃苹果,小明可以吃五个,小王可以吃三个。已知苹果园里有吃不完的苹果,求小明和小王一共最多吃多少个苹果。在这个例子中,我们可以选用的贪心策略为,每个人吃自己能吃的最多数量的苹果,这在每个人身上都是局部最优的。又因为全局结果是局部结果的简单求和,且局部结果互不相干,因此局部最优的策略也同样是全局最优的。

证明一道题能用贪心算法解决,有时远比用贪心算法解决该题更复杂。一般情况下,在简单操作后,具有明显的从局部到整体的递推关系,或者可以通过数学归纳法推测结果时,我们才会使用贪心算法。

分配问题

455. Assign Cookies
因为饥饿度最小的孩子最容易吃饱,所以我们先考虑这个孩子。为了尽量使得剩下的饼干可以满足饥饿度更大的孩子,所以我们应该把大于等于这个孩子饥饿度的、且大小最小的饼干给这个孩子。

对数组或字符串排序是常见的操作,方便之后的大小比较,排序顺序默认是从小到大。在之后的讲解中,若我们谈论的是对连续空间的变量进行操作,我们并不会明确区分数组和字符串,因为他们本质上都是在连续空间上的有序变量集合。一个字符串 “abc” 可以被看作一个数组 [“a”, “b”, “c”]。

135. Candy
存在比较关系的贪心策略并不一定需要排序。这里的贪心策略即为,在每次遍历中,只考虑并更新相邻一侧的大小关系。

Read more »

Describe Core Azure Architectural Components

Posted on 2022-04-30

Overview of Azure subscriptions, management groups, and resources

You need to learn the organizing structure for resources in Azure, which has four levels: Management Groups, Subscriptions, Resource Groups, and Resources. The following image shows the top-down hierarchy of organization for these levels:

Having seen the top-down hierarchy of organization, let’s describe each of those levels from the bottom up:

  • Resources: Resources are instances of services that you create, like VMs, storage, or SQL databases;
  • Resource groups: Resources are combined into resource groups, which act as a logical container into which Azure resources like web apps, databases, and storage accounts are deployed and managed;
  • Subscriptions: A subscription groups together user accounts and the resources that have been created by those user accounts. For each subscription, there are limits or quotas on the amount of resources that you can create and use. Organizations can use subscriptions to manage costs and the resources that are created by users, teams, or projects;
  • Management groups: They help you manage access, policy, and compliance for multiple subscriptions. All subscriptions in a management group automatically inherit the conditions applied to the management group;
Read more »

Discuss Azure Fundamental Concepts

Posted on 2022-04-27

Discuss different types of cloud models

There are three deployment models for cloud computing: Public Cloud, Private Cloud, and Hybrid Cloud. Each deployment model has different aspects that you should consider as you migrate to the cloud.

What are public, private, and hybrid clouds?

Deployment Model Description
Public Cloud Services are offered over the public internet and available to anyone who wants to purchase them. Cloud resources, such as servers and storage, are owned and operated by a third-party cloud service provider, and delivered over the internet.
Private Cloud A private cloud consists of computing resources used exclusively by users from one business or organization. A private cloud can be physically located at your organization’s on-site (on-premises) datacenter, or it can be hosted by a third-party service provider.
Hybrid Cloud A hybrid cloud is a computing environment that combines a public cloud and a private cloud by allowing data and applications to be shared between them.
Read more »

Introduction to Azure Fundamentals

Posted on 2022-04-26

What is cloud computing?

Have you ever wondered what cloud computing is? It’s the delivery of computing services over the internet, which is otherwise known as the cloud. These services include servers, storage, databases, networking, software, analytics, and intelligence. Cloud computing offers faster innovation, flexible resources, and economies of scale.

Why is cloud computing typically cheaper to use?

Cloud computing is the delivery of computing services over the internet by using a pay-as-you-go pricing model. You typically pay only for the cloud services you use, which helps you:

  • Lower your operating costs;
  • Run your infrastructure more efficiently;
  • Scale as your business needs change;

To put it another way, cloud computing is a way to rent compute power and storage from someone else’s datacenter. You can treat cloud resources like you would resources in your own datacenter. When you’re done using them, you give them back. You’re billed only for what you use.

Instead of maintaining CPUs and storage in your datacenter, you rent them for the time that you need them. The cloud provider takes care of maintaining the underlying infrastructure for you. The cloud enables you to quickly solve your toughest business challenges, and bring cutting-edge solutions to your users.

Read more »

Azure Front Door and Azure CDN

Posted on 2022-04-25

Several networking services in Azure are dedicated to application delivery. Azure Front Door and Azure CDN are services that allow us to create applications for global delivery and take advantage of the global network of Azure data centers. Leveraging this capability, we can provide the same experience to our users, irrespective of their physical location.

Create a front door instance

Azure Front Door is used for the global routing of web traffic for applications distributed across different Azure regions. With front door, we can define, manage, and monitor the routing of our web traffic and enable quick global failover. It enables us to deliver our applications with the best performance and high availability.

Front door is an L7 load balancer, similar to application gateway. However, there is a difference as regards global distribution. In terms of global distribution, it is similar to another service—traffic manager. Essentially, front door combines the best features of application gateway and traffic manager—the security of application gateway and the distribution capability of traffic manager.

The successful sample rate ensures that endpoints in the backend are available and determines how many samples are sent at a time. Successful Sample defines how many requests need to be successful in order for an endpoint to be considered healthy.

Latency Sensitivity sets the tolerance between the endpoint with the lowest latency and the rest of the endpoints. For example, let’s say the latency sensitivity setting is 30ms, while the latency of endpoint A is 15ms, that of endpoint B is 30ms, and that of endpoint C is 90ms. Endpoints A and B will be placed in the fastest pool as the difference in latency is lower than the sensitivity threshold, and endpoint C is out as it’s above the threshold.

Routing Rule defines how traffic is handled and whether specific traffic needs to be redirected or forwarded. If URL rewrite is enabled, we can construct a URL that will be forwarded to a backend. If caching is enabled, front door will cache static content for faster delivery. Front door also includes a number of configurable options and rules that can help your web applications deliver a customer- and brand-centric service.

Read more »
1…789…55
necusjz

necusjz

274 posts
16 tags
© 2016 - 2025 necusjz
Powered by Hexo
Theme - NexT.Mist