• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
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 阅读(276) 评论(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 阅读(192) 评论(0) 推荐(0)
Data Structure Array: Find the Missing Number
摘要: http://www.geeksforgeeks.org/find-the-missing-number/1. use sum formula, O(n), O(1)2. use XOR, O(n), O(1)3. use counting sort, O(n), O(1), changing the array4. use negtive, O(n), O(1), chaning the array 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9... 阅读全文
posted @ 2014-04-06 09:55 ying_vincent 阅读(159) 评论(0) 推荐(0)
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3