• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
2014年4月8日
Data Structure Array: Find the minimum distance between two numbers
摘要: http://www.geeksforgeeks.org/find-the-minimum-distance-between-two-numbers/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 int mindis(int arr[], int n, int x, int y) {12 int pre = 0;13 while (arr[pre] != x && arr[pr... 阅读全文
posted @ 2014-04-08 13:01 ying_vincent 阅读(140) 评论(0) 推荐(0)
Data Structure Array: Maximum of all subarrays of size k
摘要: http://www.geeksforgeeks.org/maximum-of-all-subarrays-of-size-k/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 void printKMax(int arr[], int n, int k) {12 deque S;13 S.push_back(0);14 for (int i = 1; i = arr[S.... 阅读全文
posted @ 2014-04-08 12:37 ying_vincent 阅读(277) 评论(0) 推荐(0)
Data Structure Array: Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
摘要: http://www.geeksforgeeks.org/given-an-array-arr-find-the-maximum-j-i-such-that-arrj-arri/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 int maxindexdiff(int arr[], int n) {12 vector L(n), R(n);13 L[0] = arr[0];14 ... 阅读全文
posted @ 2014-04-08 12:23 ying_vincent 阅读(343) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3