摘要:
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a g 阅读全文
摘要:
思路:递归。先将左子树反转,再将右子树反转,然后让root->left指向反转后的右子树,root->right指向反转后的左子树。 阅读全文
摘要:
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, giv 阅读全文
摘要:
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 阅读全文
摘要:
Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two di 阅读全文
摘要:
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime comple 阅读全文
摘要:
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 l 阅读全文
摘要:
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] 阅读全文
摘要:
The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Input: x = 1, y = 4 Output: 2 Expl 阅读全文
摘要:
思路:设原始周长为4*节点数,每当出现一次相邻的情况,原始周长会减2。 阅读全文