• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 27 下一页
2014年1月6日
LeetCode: Binary Tree Postorder Traversal
摘要: 跟inorder差不多 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * ... 阅读全文
posted @ 2014-01-06 13:52 ying_vincent 阅读(127) 评论(0) 推荐(0)
2013年11月16日
LeetCode: Linked List Cycle II
摘要: 先用双指针探到是不是有回环,假设环长为D,head到环的距离(即要找的点到head的距离)为L,慢指针走的距离为L+X,快指针比慢指针快了一个或者多个环,所以为2*(L+X),注意X next) return NULL;15 while (q && q->next) {16 ... 阅读全文
posted @ 2013-11-16 15:42 ying_vincent 阅读(159) 评论(0) 推荐(0)
2013年11月14日
LeetCode: Linked List Cycle
摘要: 双指针的简单题 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val... 阅读全文
posted @ 2013-11-14 13:22 ying_vincent 阅读(133) 评论(0) 推荐(0)
LeetCode: Length of Last Word
摘要: 简单题目 1 class Solution { 2 public: 3 int lengthOfLastWord(const char *s) { 4 // IMPORTANT: Please reset any member data you declared, as 5 // the same Solution instance will be reused for each test case. 6 int ans = 0; 7 int len = 0; 8 while (*s != '\0' && ... 阅读全文
posted @ 2013-11-14 11:42 ying_vincent 阅读(159) 评论(0) 推荐(0)
2013年11月9日
LeetCode: Gas Station
摘要: 这题跟前面做过的一题挺像 1 class Solution { 2 public: 3 int canCompleteCircuit(vector &gas, vector &cost) { 4 // IMPORTANT: Please reset any member da... 阅读全文
posted @ 2013-11-09 02:11 ying_vincent 阅读(158) 评论(0) 推荐(0)
2013年11月4日
LeetCode: Copy List with Random Pointer
摘要: 跟clone graph思路一样 1 /** 2 * Definition for singly-linked list with a random pointer. 3 * struct RandomListNode { 4 * int label; 5 * RandomL... 阅读全文
posted @ 2013-11-04 11:02 ying_vincent 阅读(182) 评论(0) 推荐(0)
2013年11月3日
LeetCode: Clone Graph
摘要: 这题的思路就是建一个old graph到新的graph点的对应map,queue表示还未访问过的old graph的点的队列,如果queue的front的点的neighbors vector里有未访问的点就添加到队列里。 1 /** 2 * Definition for undirected gr... 阅读全文
posted @ 2013-11-03 07:57 ying_vincent 阅读(235) 评论(0) 推荐(0)
2013年11月2日
LeetCode: Candy
摘要: 这题就是从左到右对递增的点进行刷点,再从右到左对递增的点进行刷点。时间复杂度和空间复杂度都为O(n)。注意如果两个相邻的点ratings一样,则不必保持candy数一样(个人认为很不合理). 1 class Solution { 2 public: 3 int candy(vector &r... 阅读全文
posted @ 2013-11-02 08:45 ying_vincent 阅读(212) 评论(0) 推荐(0)
2013年10月13日
Database: Normal form
摘要: refer to wikipedia---1NF(first normal form):1. There's no top-to-bottom ordering to the rows.2.There's no left-to-right ordering to the columns.3.There are no duplicate rows.4.Every row-and-column intersection contains exactly one value from the applicable domain (and nothing else).5.All col 阅读全文
posted @ 2013-10-13 06:21 ying_vincent 阅读(474) 评论(0) 推荐(0)
2013年10月2日
Algorithm: cartesian tree
摘要: http://baike.baidu.com/link?url=XUt5fXQ-jtFBM0UdKiGA41_NWFvdFSYwVsy4SVvCRRuEBvNkLfT9TgOtzsXvaOT9nuq_EzKJcO0gt6nyXRSLU_这里有详细介绍有一道coding test的题目给你一个int n, 一串float的数,要你实时打印出当前数到这个数前n个数这n个数里最大值,没有n个数就是前面那几个数的最大值。这里就可以用cartesian tree,label记录是数的下标,p表示数值。插入操作为lg(n), 删除操作也为lg(n),总的复杂度为Nlg(n). 1 #include ... 阅读全文
posted @ 2013-10-02 18:19 ying_vincent 阅读(296) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 27 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3