BAZINGA

BAZINGA's Blog


  • Home

  • About

  • Tags

  • Archives

13. Roman to Integer

Posted on 2018-04-12 |

题目

Given a roman numeral, convert it to an integer.

Input is guaranteed to be within the range from 1 to 3999.

Read more »

9. Palindrome Number

Posted on 2018-04-12 |

题目

Determine whether an integer is a palindrome. Do this without extra space.

Read more »

121. Best Time to Buy and Sell Stock

Posted on 2018-02-06 |

题目

Say you have an array for which the i^th element is the price of a given stock on day i.

If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.

Example 1:

1
2
3
4
Input: [7, 1, 5, 3, 6, 4]
Output: 5

max. difference = 6-1 = 5 (not 7-1 = 6, as selling price needs to be larger than buying price)

Example 2:

1
2
3
4
Input: [7, 6, 4, 3, 1]
Output: 0

In this case, no transaction is done, i.e. max profit = 0.
Read more »

排序算法

Posted on 2018-01-25 |

排序算法是最基本最常用的算法,是算法与数据结构的基础,也是面试中常见的一类问题。

Read more »

15. 3Sum

Posted on 2018-01-23 |

题目

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

Note: The solution set must not contain duplicate triplets.

For example, given array S = [-1, 0, 1, 2, -1, -4],

A solution set is:
[
[-1, 0, 1],
[-1, -1, 2]
]

Read more »
123…21

BAZINGA

105 posts
23 tags
RSS
GitHub
Links
  • 高明飞的博客
  • 今天没有拉肚子的博客
© 2015 — 2018 BAZINGA
Theme — NexT.Pisces v6.0.1