http://www.geeksforgeeks.org/find-the-minimum-distance-between-two-numbers/

 #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <fstream>
#include <map>
using namespace std; int mindis(int arr[], int n, int x, int y) {
int pre = ;
while (arr[pre] != x && arr[pre] != y) pre++;
int i = pre + ;
int ans = n;
for (; i < n; i++) {
if (arr[i] != x && arr[i] != y) continue;
if (arr[i] != arr[pre]) ans = min(ans, i - pre);
pre = i;
}
return ans;
} int main() {
int arr[] = {, , , , , , , , , , , };
cout << mindis(arr, , , ) << endl;
return ;
}

最新文章

  1. python3-day1-python简介及入门
  2. js如何判断一个数组
  3. 03-VTK基础概念(2)
  4. 机器翻译(noip2010)
  5. Java基础知识强化之IO流笔记63:随机访问流RandomAccessFile
  6. Android Sutido 编译速度优化
  7. Asp.net实现在线人数统计功能代码实例
  8. (2010-8-31) awk内存泄漏以及缓慢的正则表达式计算速度
  9. WordPress插件制作笔记(二)---Second Plugins Demo
  10. mysql进阶(八)怎么对varchar类型排序问题
  11. 500G !!史上最全的JAVA全套教学视频网盘分享 (JEECG开源社区)
  12. Docker面试题
  13. 通过iostat来查看linux硬盘IO性能|实例分析
  14. Win10系列:C#应用控件基础11
  15. Hadoop 4 MapReduce
  16. Python3基础 try-except else进行配合
  17. 2018.07.06 POJ 1459 Power Network(多源多汇最大流)
  18. 第7章 使用寄存器点亮LED灯—零死角玩转STM32-F429系列
  19. Mondrian系列
  20. Linux命令-目录处理命令:cd

热门文章

  1. [linux]netstat命令详解-显示linux中各种网络相关信息
  2. Spark on Intellij IDEA
  3. javax.mail Java Extension(扩展)
  4. Paxos 学习总结
  5. css 温故而知新 select-option 文字方向居右
  6. [LeetCode]Palindrome Number 推断二进制和十进制是否为回文
  7. Java和C++ 比較
  8. org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: Unknown column &#39;viewpoint&#39; in &#39;field list&#39;
  9. linux 上拷贝文件到windows 上 文件出现锁的文件
  10. 多媒体开发之--- h264 图像、帧、片、NALU