两个指针方法 [英] Two pointer method

查看:141
本文介绍了两个指针方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我在codeforces编程竞赛中遇到的问题。问题的标签称为该问题可以通过使用两个指针的方法来解决。
究竟什么是两指针方式?

Recently i came across a question during a programming contest on codeforces. Problem tags referred that the problems could be solved by using two pointer method. What exactly is the Two Pointer Method?

推荐答案

从我可以在这些链接告诉,两指针法仅仅是指索引到使用两个不同的指标两个不同的阵列(他们指的是阵列指数为指针,这是大多数C程序员如何使用这个词)有所不同。

From what I can tell at those links, the "two pointer method" simply refers to indexing into two different arrays using two different indices (they refer to the array indices as pointers, which is somewhat different from how most C programmers use the term).

他们中的问题的情况下使用它像

They were using it in context of a problem like

if (a[i] + b[j] == X)
  // do something with i and j

其中, I Ĵ为指针(在指针一词的一般意义,而不是ç数据类型意义上的)。

where i and j were the pointers (in the generic sense of the term "pointer", not the C datatype sense).

这是没有什么可怕的异国情调,而直到今天我不知道任何人创造了它一个特定术语。

This isn't anything terribly exotic, and until today I had no idea that anyone had coined a specific term for it.

当你跟大多数C程序员,像二指针法的一个术语意味着什么涉及双反引用,如

When you talk to most C programmers, a term like "two pointer method" would imply something involving a double dereference, such as

x = **p;

这是没有像他们在codeforces链接说什么。

which is nothing like what they're talking about at the codeforces link.

这篇关于两个指针方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆