![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
刷题
文章平均质量分 66
叶晚林
学习路上。
展开
-
LeetCode|Merge Two Sorted Lists
【问题描述】Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.【解答1】特殊情况:若有一个链表为空,则返回另一个链表。class Solution {原创 2016-08-11 22:51:00 · 400 阅读 · 0 评论 -
和树相关的题目思路分析与总结
和树相关的术语:高度深度层和树相关的基本算法:遍历计算高度计算深度DFSBFS树的遍历:前序遍历中序遍历后序遍历层次遍历树中基本的解题方法:递归套用遍历的思路迭代的方法一般需要用队列或栈遍历...原创 2019-07-19 10:18:05 · 169 阅读 · 0 评论 -
剑指offer|把数组排成最小的数
【题目描述】输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。时间限制:1秒 空间限制:32768K 热度指数:237731本题知识点: 数组【解题思路】需要的考虑的两个问题:带比较器的排序 - 自定义比较规则隐含的大数问题 - 将int数组转为字符串i...原创 2019-05-23 11:37:42 · 81 阅读 · 0 评论 -
剑指offer|整数中1出现的次数(从1到n整数中1出现的次数)
【题目描述】求出1-13的整数中1出现的次数,并算出100-1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1、10、11、12、13因此共出现6次,但是对于后面问题他就没辙了。ACMer希望你们帮帮他,并把问题更加普遍化,可以很快的求出任意非负整数区间中1出现的次数(从1 到 n 中1出现的次数)。时间限制:1秒 空间限制:32768K 热度指数:178594【解题...原创 2019-05-23 11:30:08 · 139 阅读 · 0 评论 -
剑指offer|丑数
【题目描述】把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。时间限制:1秒 空间限制:32768K 热度指数:265042本题知识点: 数组【思路分析】法一:暴力求解法了解并书写判断一个数是不是丑数的规则;从1开始,依次判断是否为丑数,是则丑数计数器...原创 2019-05-24 11:46:53 · 118 阅读 · 0 评论 -
剑指offer|字符串的排列
【题目描述】输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。输入描述:输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母。时间限制:1秒 空间限制:32768K 热度指数:378352本题知识点: 字符串【解题思路】把字符串分为两部分:一部分...原创 2019-05-15 20:12:00 · 8115 阅读 · 0 评论 -
剑指offer|二叉树中和为某一值的路径
【题目描述】输入一颗二叉树的跟节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。(注意: 在返回值的list中,数组长度大的数组靠前)时间限制:1秒 空间限制:32768K 热度指数:343027【解题思路】运用前序遍历递归解决。结合路径的概念:到达叶结点时判断target和current是否相等,相等则...原创 2019-04-29 15:47:49 · 96 阅读 · 0 评论 -
剑指offer|树的子结构
【题目描述】输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构)时间限制:1秒 空间限制:32768K 热度指数:432114【解题思路】第一步,在树A中找到和树B的根结点的值一样的结点R;第二步,判断树A中以从R为根结点的子树中是不是包含和树B一样的结构。8 8/ \ ...原创 2019-04-22 19:17:32 · 104 阅读 · 0 评论 -
剑指offer|合并两个排序的链表
【题目描述】输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。时间限制:1秒 空间限制:32768K 热度指数:446096本题知识点: 链表【解题思路】递归版本:递归调用Merge()通过next连接就可以了;非递归版本:注意处理头结点(定义两个结点,初始时两者都指向第一个结点处,last结点进行next操作构造链表,head结点在指向第一个...原创 2019-04-22 17:04:52 · 203 阅读 · 0 评论 -
Leetcode|136. Single Number
【问题描述】Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without ...原创 2018-05-15 10:26:37 · 445 阅读 · 0 评论 -
leetcode|88. Merge Sorted Array
问题描述:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that...原创 2018-04-21 17:18:00 · 144 阅读 · 0 评论 -
leetcode|66. Plus One
问题描述:Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each elem...原创 2018-04-19 21:33:24 · 284 阅读 · 0 评论 -
leetcode|58. Length of Last Word
问题描述:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defi...原创 2018-04-19 20:54:02 · 220 阅读 · 0 评论 -
LeetCode|Reverse Linked List
【问题描述】Reverse a singly linked list.【解答】class Solution {public: ListNode* reverseList(ListNode* head) { if(head==NULL || head->next==NULL) return head; ListNode* pre=NULL;原创 2016-08-12 15:42:19 · 303 阅读 · 0 评论 -
LeetCode|Intersection of Two Linked Lists
【问题描述】Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2 ↘原创 2016-08-12 09:42:10 · 317 阅读 · 0 评论 -
LeetCode|Remove Nth Node From End of List
【问题描述】Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the原创 2016-08-09 10:58:44 · 343 阅读 · 0 评论 -
LeetCode|Remove Duplicates from Sorted List
【问题描述】Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.【解答】运用一个附加指针来记原创 2016-08-09 21:50:32 · 290 阅读 · 0 评论 -
刷题|和链表相关的题目思路分析与总结
刷题|和链表相关的题目思路分析与总结1 数据结构1.1 单链表1.2 循环链表1.3 双向链表1.4 链表和数组对比1 数据结构1.1 单链表链表通过指针将一组零散的内存块串联在一起。把内存块称为链表的“结点”。为了将所有的结点串联起来,每个链表的结点除了存储数据之外,还需要记录链上的下一个结点地址。把这个记录下个结点地址的指针叫做后继指针next。看了上面的描述最基本的单链表的...原创 2019-08-03 12:50:06 · 647 阅读 · 1 评论