ZMR小站

很高兴遇见你~


  • 首页

  • 标签

  • 分类

  • 归档

p94

发表于 2016-07-26 | 分类于 blog

LeetCode 94 Binary Tree Inorder Traversal 题解

1.题目:

Given a binary tree, return the inorder traversal of its nodes’ values.
For example:
Given binary tree [1,null,2,3],

1
\
2
/
3

return [1,3,2].

阅读全文 »

p144

发表于 2016-07-26 | 分类于 blog

LeetCode 144 Binary Tree Preorder Traversal 题解

1.题目:

Given a binary tree, return the preorder traversal of its nodes’ values.

For example:
Given binary tree {1,#,2,3},

1
\
2
/
3

return [1,2,3].

阅读全文 »

p319

发表于 2016-07-26 | 分类于 blog

LeetCode 319 Bulb Switcher 题解

1.题目:

There are n bulbs that are initially off. You first turn on all the bulbs.
Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off if it’s on).
For the ith round, you toggle every i bulb.
For the nth round, you only toggle the last bulb. Find how many bulbs are on after n rounds.
Example:
Given n = 3.
At first, the three bulbs are [off, off, off].
After first round, the three bulbs are [on, on, on].
After second round, the three bulbs are [on, off, on].
After third round, the three bulbs are [on, off, off].
So you should return 1, because there is only one bulb is on.

阅读全文 »

p268

发表于 2016-07-12 | 分类于 blog

LeetCode 268 Missing Number 题解

1.题目:

Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.
For example,
Given nums = [0, 1, 3] return 2.

阅读全文 »

p343

发表于 2016-06-09 | 分类于 blog

LeetCode P343 Reverse String 题解

1.题目:

Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.

For example, given n = 2, return 1 (2 = 1 + 1); given n = 10, return 36 (10 = 3 + 3 + 4).

Note: you may assume that n is not less than 2.

题意:给一个数,返回他拆分之后乘积最大的答案 乘的越多次越好

阅读全文 »

p350

发表于 2016-06-06 | 分类于 blog

LeetCode 350 Intersection of Two Arrays II 题解

1.题目:

Given two arrays, write a function to compute their intersection.

Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].

阅读全文 »

p217

发表于 2016-06-06 | 分类于 blog

LeetCode 217 Contains Duplicate 题解

1.题目:

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 false if every element is distinct.

阅读全文 »
1…282930…33
ZhangMengRou

ZhangMengRou

ZMR小站

230 日志
4 分类
14 标签
© 2019 ZhangMengRou
由 Hexo 强力驱动
|
主题 — NexT.Gemini v5.1.4