• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 27 下一页
2014年4月9日
Data Structure Array: Sort elements by frequency
摘要: http://www.geeksforgeeks.org/sort-elements-by-frequency-set-2/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 void printarray(int arr[], int n) {12 map S;13 for (int i = 0; i > T;18 for (map::iterator it = S.be... 阅读全文
posted @ 2014-04-09 12:56 ying_vincent 阅读(261) 评论(0) 推荐(0)
Data Structure Array: Maximum circular subarray sum
摘要: http://www.geeksforgeeks.org/maximum-contiguous-circular-sum/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 bool allneg(int arr[], int n) {12 for (int i = 0; i 0) return false;14 }15 return true;16 }17 18 int ... 阅读全文
posted @ 2014-04-09 10:06 ying_vincent 阅读(184) 评论(0) 推荐(0)
Data Structure Array: Largest subarray with equal number of 0s and 1s
摘要: http://www.geeksforgeeks.org/largest-subarray-with-equal-number-of-0s-and-1s/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 void findsubarray(int arr[], int n) {12 map > S;13 int sum = 0;14 for (int i = 0; i (1... 阅读全文
posted @ 2014-04-09 06:28 ying_vincent 阅读(409) 评论(0) 推荐(0)
Data Structure Array: Find the two numbers with odd occurrences in an unsorted array
摘要: http://www.geeksforgeeks.org/find-the-two-numbers-with-odd-occurences-in-an-unsorted-array/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 void printtwoodd(int arr[], int n) {12 int x = arr[0];13 for (int i = 1; i <... 阅读全文
posted @ 2014-04-09 05:44 ying_vincent 阅读(185) 评论(0) 推荐(0)
Data Structure Array: Longest Monotonically Increasing Subsequence Size
摘要: http://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 int maxsum(int arr[], int n) {12 vector tail;13 tail.push_back(arr[0]);14 fo... 阅读全文
posted @ 2014-04-09 05:09 ying_vincent 阅读(258) 评论(0) 推荐(0)
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)
2014年4月6日
Data Structure Array: Maximum sum such that no two elements are adjacent
摘要: http://www.geeksforgeeks.org/maximum-sum-such-that-no-two-elements-are-adjacent/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 int maxsum(int arr[], int n) {12 int insum = arr[0];13 int exsum = 0;14 for (int i ... 阅读全文
posted @ 2014-04-06 12:12 ying_vincent 阅读(274) 评论(0) 推荐(0)
Data Structure Array: Program for array rotation
摘要: http://www.geeksforgeeks.org/array-rotation/O(n), O(1) 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 int gcd(int a, int b) {12 return b == 0? a : gcd(b, a % b);13 }14 15 void leftrotate(int arr[], int d, int n) {16 ... 阅读全文
posted @ 2014-04-06 10:40 ying_vincent 阅读(190) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 27 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3