- 博客(21)
- 资源 (1)
- 收藏
- 关注
原创 1002. A+B for Polynomials (25)
This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a p
2017-02-20 09:14:28 267
原创 1001. A+B Format (20)
Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).InputEach input file cont
2017-02-20 08:31:47 294
原创 226. Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by Max Howe
2016-09-29 15:47:25 171
原创 167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two number
2016-09-29 15:41:40 167
原创 389. Find the Difference
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was
2016-09-29 14:56:30 164
原创 104. 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 leaf node.int maxDepth(struct TreeNode* root
2016-09-28 22:21:56 159
原创 258. 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 on
2016-09-28 22:07:55 182
原创 136. 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 implement it without using e
2016-09-28 21:45:03 176
原创 371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.int getSum(int a, int b) { int result = a ^ b;
2016-09-27 22:37:32 166
原创 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the
2016-09-27 21:35:01 142
原创 338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5
2016-09-27 21:24:13 158
原创 21. 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.struct ListNode* mergeTwoLists(struct ListNode* l1, str
2016-09-26 22:26:56 176
原创 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y
2016-09-26 22:25:39 137
原创 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?快慢指针,但不额外占用空间的方法没找到。/** * Definition for singly-linked list. * struct ListNode
2016-09-26 22:22:39 172
原创 83. Remove Duplicates from Sorted List
For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.开始的时候想着还要free啥的,结果超时,果断去掉free,AC。。有一点需要注意,链表中有连续两个以上重复元素的处理方式。代码贴上/** * Definition for singly-linked list.
2016-09-21 23:00:52 149
原创 328. 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 should try to do it in
2016-09-21 22:20:06 147
原创 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value
2016-09-21 20:28:54 132
原创 206. Reverse Linked List
Reverse a singly linked list.递归与指针实现代码贴上#include struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} };class Solution {public: ListNode* reverse
2016-09-21 20:27:19 164
原创 树的同构
给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。图1图2现给定两棵树,请你判断它们是否是同构的。输入格式:输入给出2棵二叉树树的信息。对于每棵树
2016-09-17 17:08:33 607
原创 Pop Sequence
Given a stack which can keep MM numbers at most. Push NN numbers in the order of 1, 2, 3, ..., NN and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequ
2016-09-15 17:28:34 273
原创 Reversing Linked List
Given a stack which can keep MM numbers at most. Push NN numbers in the order of 1, 2, 3, ..., NN and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequ
2016-09-12 22:19:41 349
操作系统真象还原pdf
2018-04-19
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人