LeetCode bug记录
2016-04-12 21:29
459 查看
指针操作:
刚开始做指针操作时,容易出现思路混乱的问题,导致代码混乱,
整理好思路,每个操作着眼于意义,而不是直接是操作,如tree的遍历过程,递归的时候,对于每次函数调用,都会遇到什么情况,每种情况怎么处理,然后建立分支。
细节上,注意循环指数。不要急,慢慢写
数组访问越界的时候也会导致Time Limited Execuded
访问NULL指针指向的数据则会报RunTime Error
Palindrome Linked List
一直出现Time Limited Execuded
是因为在将一个完整的单向链表从中间进行反转时,即将链表的后半段反转,
反转后,形成两个链表,没有将这两个链表的末尾置NULL
Rectangle Area
这个题,刚拿到手觉得好简单,给别人说,给我10分钟,马上搞定,
结果折腾了半个小时,
因为各种情况考虑不周全, 呃呃呃,晕了个擦嘞
(也不是情况太多,是我抽象的不好)
刚开始做指针操作时,容易出现思路混乱的问题,导致代码混乱,
整理好思路,每个操作着眼于意义,而不是直接是操作,如tree的遍历过程,递归的时候,对于每次函数调用,都会遇到什么情况,每种情况怎么处理,然后建立分支。
细节上,注意循环指数。不要急,慢慢写
数组访问越界的时候也会导致Time Limited Execuded
访问NULL指针指向的数据则会报RunTime Error
Palindrome Linked List
一直出现Time Limited Execuded
是因为在将一个完整的单向链表从中间进行反转时,即将链表的后半段反转,
反转后,形成两个链表,没有将这两个链表的末尾置NULL
Rectangle Area
这个题,刚拿到手觉得好简单,给别人说,给我10分钟,马上搞定,
结果折腾了半个小时,
因为各种情况考虑不周全, 呃呃呃,晕了个擦嘞
(也不是情况太多,是我抽象的不好)
相关文章推荐
- leetcode 179 Largest Number
- leetcode 24 Swap Nodes in Pairs
- leetcode 2 Add Two Numbers 方法1
- leetcode 2 Add Two Numbers 方法2
- leetcode----Longest Substring Without Repeating Characters
- [LeetCode]47 Permutations II
- [LeetCode]65 Valid Number
- [LeetCode]123 Best Time to Buy and Sell Stock III
- [LeetCode] String Reorder Distance Apart
- [LeetCode] Sliding Window Maximum
- [LeetCode] Find the k-th Smallest Element in the Union of Two Sorted Arrays
- [LeetCode] Determine If Two Rectangles Overlap
- [LeetCode] A Distance Maximizing Problem
- leetcode_linearList
- leetcode_linearList02
- 021-Merge Two Sorted Lists(合并两个排好序的单链表);leetcode
- LeetCode[Day 1] Two Sum 题解
- LeetCode[Day 2] Median of Two Sorted Arrays 题解
- LeetCode[Day 3] Longest Substring Without... 题解
- LeetCode [Day 4] Add Two Numbers 题解