11 2015 档案
摘要:C++ 1 class Solution { 2 public: 3 /** 4 * @param x: An integer 5 * @return: The sqrt of x 6 */ 7 int sqrt(int x) { 8 /...
阅读全文
摘要:C++逆推 1 class Solution { 2 public: 3 /** 4 * @param triangle: a list of lists of integers. 5 * @return: An integer, minimum path sum. 6 ...
阅读全文
摘要:C++双向递推空间O(1)时间O(n) 1 class Solution { 2 public: 3 /** 4 * @param A an array of Integer 5 * @return an integer 6 */ 7 int long...
阅读全文
摘要:C++Divide-Conquer[71% passed] 1 class Solution { 2 public: 3 /** 4 * @param nums: a list of integers 5 * @return: A integer denote the s...
阅读全文
摘要:C++dp递推式:dp[i][j] = dp[i-1][j] + dp[i][j-1]初值:dp[i][j] = 1,i=0 or j=0空间优化:省掉一维 1 class Solution { 2 public: 3 /** 4 * @param n, m: positive i...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /** 4 *@param a, b: Two integer 5 *return: An integer 6 */ 7 int bitSwapRequired(int a, int ...
阅读全文
摘要:dp注意问题 递推式 初值 空间优化1. bfs题目里有“最小”字样,符合bfs关键词:上界len(S)+len(T)实际上不可行;2. dp删除字符很麻烦换个角度,变为字符串“对齐问题”:S = ABCFT = DBFGS:A B C F -T:D B - F G对应位置相同则不扣分,不同则...
阅读全文
摘要:1. 暴力枚举2. “聪明”枚举3. 分治法分:两个基本等长的子数组,分别求解T(n/2)合:跨中心点的最大子数组合(枚举)O(n)时间复杂度:O(n*logn) 1 class Solution { 2 public: 3 /** 4 * @param nums: A l...
阅读全文
摘要:C++,time: O(m*n)space: O(m*n) 1 class Solution { 2 public: 3 /** 4 * @param grid: a list of lists of integers. 5 * @return: An integer, ...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /** 4 * @param n the nth 5 * @return the nth sequence 6 */ 7 string countAndSay(int n) { 8 ...
阅读全文
摘要:C++/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->v...
阅读全文
摘要:C++ 1 /** 2 * Definition of TreeNode: 3 * class TreeNode { 4 * public: 5 * int val; 6 * TreeNode *left, *right; 7 * TreeNode(int val...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /** 4 * @param num: an integer 5 * @return: an integer, the number of ones in num 6 */ 7 int...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /** 4 * @param A: An integer array. 5 * @param B: An integer array. 6 * @return: Cosine similari...
阅读全文
摘要:C++,time: O(n^2)space: O(0)class Solution {public: /** * @param str: a string * @return: a boolean */ bool isUnique(string &str) { ...
阅读全文
摘要:C++,time: O(n)space:O(n) 1 class Solution { 2 public: 3 /** 4 * @param str: a string 5 * @param offset: an integer 6 * @return: not...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /** 4 * @param dictionary: a vector of strings 5 * @return: a vector of strings 6 */ 7 vecto...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /** 4 * @param A: A string includes Upper Case letters 5 * @param B: A string includes Upper Case let...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /** 4 * @param n: An integer 5 * @return: An integer 6 */ 7 int climbStairs(int n) { 8 ...
阅读全文
摘要:C++,递归 1 /** 2 * Definition of TreeNode: 3 * class TreeNode { 4 * public: 5 * int val; 6 * TreeNode *left, *right; 7 * TreeNode(int ...
阅读全文
摘要:C++,递归 1 /** 2 * Definition of TreeNode: 3 * class TreeNode { 4 * public: 5 * int val; 6 * TreeNode *left, *right; 7 * TreeNode(int ...
阅读全文
摘要:C++,递归,辅助函数 1 /** 2 * Definition of TreeNode: 3 * class TreeNode { 4 * public: 5 * int val; 6 * TreeNode *left, *right; 7 * TreeNode...
阅读全文
摘要:C++ 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x),...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /** 4 * @param a a number 5 * @param b a number 6 * @return the result 7 */ 8 string ad...
阅读全文
摘要:C++ 1 class Solution { 2 public: 3 /* 4 * @param a: The first integer 5 * @param b: The second integer 6 * @return: The sum of a an...
阅读全文
摘要:C++ 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x),...
阅读全文
摘要:C++ 1 class Solution{ 2 public: 3 /** 4 * @param n: an integer 5 * @return an integer f(n) 6 */ 7 int fibonacci(int n) { 8 ...
阅读全文
摘要:Hybrid App越来越火,Ionic的框架也逐渐被更多的人熟知。 在mobile app中,消息推送是很必要的一个功能。 国内很多ionic应用的推送都是用的极光推送,最近研究了一下Ionic自己做的推送,由于它自己官方文档不是很详细并且基于很多假设(假设读者熟悉Apple Develo...
阅读全文