![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔记
文章平均质量分 61
air1tmac
这个作者很懒,什么都没留下…
展开
-
104 Maximum Depth of Binary Tree
目录原题描述分析代码示例原题描述Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest lea原创 2015-07-27 22:14:40 · 124 阅读 · 0 评论 -
328 Odd Even Linked List
原题描述Odd Even Linked List Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You s原创 2016-03-16 19:12:02 · 123 阅读 · 0 评论 -
287 Find the Duplicate Number
原题描述Find the Duplicate Number Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is原创 2016-03-16 15:58:15 · 174 阅读 · 0 评论 -
258 Add Digits
原题描述Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has o原创 2015-08-18 15:21:31 · 119 阅读 · 0 评论 -
242 Valid Anagram
原题描述Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.Note: Y原创 2015-08-04 15:25:32 · 142 阅读 · 0 评论 -
141 Linked List Cycle
原题描述Linked List Cycle Given a linked list, determine if it has a cycle in it.分析如果链表有环,则从表头开始向后索引时总会回到之前到达过的节点。考虑使用map记录这个节点,然后在向后索引过程中查找map中是否存在这个节点,则可以判断是否存在环。代码示例/** * Definition for singly-linked原创 2015-08-04 15:33:28 · 170 阅读 · 0 评论 -
行号
/* 示例3-1.CPP 公有继承示例*/class Student // 声明基类{ private: int num; string name; char sex; public: void get_value() { cin >> num >> name >> sex; } void display() { cout << "num: " << num << endl; cout << "n原创 2015-08-13 13:16:27 · 73 阅读 · 0 评论 -
226 Invert Binary Tree
原题描述Invert Binary Tree Invert a binary tree.4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1分析将二叉树翻转,即对于每个节点都将其左右子树交换,因此对二叉树做一次遍历即可。为了直观,我们使用层原创 2015-07-30 11:16:28 · 161 阅读 · 0 评论 -
171 Excel Sheet Column Number
原题描述Excel Sheet Column Number Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...原创 2015-07-29 21:44:01 · 102 阅读 · 0 评论 -
136 Single Number
目录原题描述分析代码示例原题描述Single Number Given an 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 im原创 2015-07-28 12:48:30 · 118 阅读 · 0 评论 -
100 Same Tree
目录原题描述分析代码示例原题描述Same Tree Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the s原创 2015-07-28 12:57:06 · 226 阅读 · 1 评论 -
122 Best Time to Buy and Sell Stock II
目录原题描述分析代码示例注意原题描述Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may原创 2015-07-28 16:00:59 · 103 阅读 · 0 评论 -
206 Reverse Linked List
原题描述Reverse Linked List Reverse a singly linked list.分析使用递归,将链表反向转化为两个节点的反向。策略为先将后一节点反向,再把后一节点指向前一节点。最后记住将之前的头指针指向NULL。代码示例/** * Definition for singly-linked list. * struct ListNode { * int val原创 2016-03-10 14:55:03 · 146 阅读 · 0 评论