摘要:附加一道 同样使用记忆化搜索的题目 329. Longest Increasing Path in a Matrix
阅读全文
摘要:二叉树的序列化与反序列化。 如果使用string作为媒介来存储,传递序列化结果的话,会给反序列话带来很多不方便。 这里学会了使用 sstream 中的 输入流'istringstream' 和 输出流'ostringstream'. istringstream in; in >> str; 这里没执
阅读全文
摘要:非递归中序遍历: 思路:注释 非递归前序遍历:
阅读全文
摘要:Search in Rotated Sorted Array 分段有序的数组,二分查找返回下标,没有返回-1 数组有序之后经过 rotated, 比如:6 1 2 3 4 5 or 5 6 7 8 1 2 思路是: (1)nums[m] == target return m (2)必定有一段是有序的
阅读全文
摘要:最近搞了几场编程比赛,面试题或者是LeetCode周赛。每次都不能做完,发现时间不够用。 看了别人的代码才知道,同样实现相同的功能,可能别人只需要用一个恰当的函数,就会比自己少些不少代码,争得了时间。所以这些小技巧对于提升名次来说,十分重要。以后需要 更加重视才行。 拿LeetCode Weekly
阅读全文
摘要:2.一个游戏 YouTube MIT 算法课上有详细的讲解 思路是DP。 话说MIT OpenCourseWare 真心不错。应该好好看看,讲的详细生动。 Tips: 1.当n是偶数的时候,首先的选择的player必赢。 当n是奇数的时候,我们可以通过dp[i, j]来算出在player1的轮次下(
阅读全文
摘要:480. Sliding Window Median Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the me
阅读全文
摘要:Today, Leet weekly contest was hold on time. However, i was late about 15 minutes for checking out of the hotel. It seems like every thing gone well.
阅读全文
摘要:Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyza
阅读全文
摘要:Description: A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and n
阅读全文
摘要:Description: Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part
阅读全文
摘要:Description: For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Analysis: The problem can be solved by sorting. It's realllll
阅读全文
摘要:This a task that asks u to compute the maximum product from a continue subarray. However, you need to watch out the values' type contains positive, ne
阅读全文
摘要:Description: Given two string S and T, you need to count the number of T's subsequences appeared in S. The fucking problem description is so confusing
阅读全文
摘要:Description: Given arrays recording 'Preorder and Inorder' Traversal (Problem 105) or 'Inorder and Postorder' (Problem 106), u need build the binary t
阅读全文
摘要:This is a BST(binary search tree) numbers counting problem but solved in dynamic programing. https://discuss.leetcode.com/category/104/unique-binary-s
阅读全文
摘要:The task is reversing a list in range m to n(92) or a whole list(206). All in one : U need three pointers to achieve this goal. 1) Pointer to last val
阅读全文
摘要:Yesterday, Bro Luo told me: "Why don't you improve your English by writing your blogs in English?" I think it may be a good way and i did so today. Pr
阅读全文
摘要:问题描述: https://leetcode.com/problems/single-number-iii/ 在一个数组里面,只有两个元素仅出现过1次,其余都出现过两次。找出出现仅一次的那两个(a, b)。 要求常量空间,线性时间。 问题解决: 这题用到“神奇的位运算”。 1.因为除了特殊的两个元素
阅读全文
摘要:问题描述: 给定一个list, 将所有小于x的node放到左边,剩下的保持原样。 问题解决: 闲的无聊,用c++和python都做了一遍。 代码如下: 第一个py,解决了个小问题。加油吧~~
阅读全文