
Algorithm
ray3044
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Reverse Integer - Recursion & Iteration
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask before c原创 2014-11-18 11:34:00 · 334 阅读 · 0 评论 -
Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]原创 2014-11-20 06:35:18 · 293 阅读 · 0 评论 -
Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? 1st iteratio原创 2014-11-20 04:46:03 · 287 阅读 · 0 评论 -
Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a原创 2014-11-19 07:31:00 · 321 阅读 · 0 评论 -
Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of convertin原创 2014-11-19 05:49:13 · 266 阅读 · 0 评论 -
Longest Common Prefix
first iteration class Solution { public: string longestCommonPrefix(vector &strs) { string prefix; // empty string vector if (strs.empty()) {原创 2014-11-20 03:32:59 · 298 阅读 · 0 评论 -
Symmetric Tree - Recursion & Iteration
class Solution { public: bool isSymmetric(TreeNode *root) { if (root == NULL) { return true; } std::queue q; q.push(root); siz原创 2014-11-15 03:44:58 · 409 阅读 · 0 评论 -
Valid Sudoku
My first implementation:原创 2014-11-18 06:42:07 · 268 阅读 · 0 评论 -
Count and Say
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as原创 2014-11-18 11:46:51 · 253 阅读 · 0 评论 -
String to Integer (atoi)
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca原创 2014-11-18 13:19:49 · 314 阅读 · 0 评论 -
Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree and sum原创 2014-11-20 06:56:30 · 237 阅读 · 0 评论