随笔分类 -  LeetCode

LeetCode题解
LeetCode101.Symmetric Tree
摘要:题目 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is sym 阅读全文

posted @ 2017-08-17 00:11 GyyZyp 阅读(582) 评论(0) 推荐(0)

【外企面试】求一个链表中环的入口【强势证明】
摘要:此题没有代码,是一道面试题。题目很好理解,有个链表,先判断是否有环,如果有环则求出环的入口。 这道题跟好几位offer收割机讨论过,基本都是已知leetcode或哪里的方法,证明该方法的正确性。 我和我家阳哥,试图证明,策略是可以推导出来的。证明如下: 首先,要判断一个链表是否有环,机智的做法是快慢 阅读全文

posted @ 2017-05-12 19:44 GyyZyp 阅读(389) 评论(0) 推荐(0)

LeetCode5. Longest Palindromic Substring 最长回文子串 4种方法
摘要:题目链接:https://leetcode.com/problems/longest-palindromic-substring/ 题意很简单,就是求一个字符串得最长子串,这里的子串指连续的。 本文给出四个不同时间的解法。在LeetCode上的用时分别是500ms,250ms,60ms以及6ms。 阅读全文

posted @ 2017-01-02 13:11 GyyZyp 阅读(201) 评论(0) 推荐(0)

LeetCode4. Median of Two Sorted Arrays---vector实现O(log(m+n)--- findkth
摘要:这道题目和PAT上的1029是同一题。但是PAT1029用O(m+n)的时间复杂度(题解)就可以,这道题要求是O(log(m+n))。 这道题花费了我一个工作日的时间来思考。因为是log因而一直思考如何进行二分,想着是两个vector分别二分,但一直想不到合适的解法,就是无穷尽的if else 后来 阅读全文

posted @ 2016-12-01 20:38 GyyZyp 阅读(455) 评论(0) 推荐(0)

LeetCode3. Longest Substring Without Repeating Characters
摘要:(0)前言 本来不打算在博客里面记录自己刷LeetCode的经过。做了几道题目以后发现可以AC倒是不假,但是使用的方法在时间效率上平均只能打败50%左右的用户。因而决定还是记录一下,不该小瞧这些基础的题目,它们自有存在的价值。 (一)题意 题目链接:https://leetcode.com/prob 阅读全文

posted @ 2016-11-30 21:07 GyyZyp 阅读(337) 评论(0) 推荐(0)

导航