- 博客(15)
- 资源 (1)
- 收藏
- 关注
原创 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
原创 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
原创 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
原创 217 Contains Duplicate
原题描述Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return fa
2015-08-21 15:50:37
156
原创 260 Single Number III
原题描述Single Number III Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For ex
2015-08-18 17:17:08
143
原创 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
原创 行号
/* 示例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
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人