leetcode Patching Array
Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range
[1, n]inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required.
[1, 3], n =
Combinations of nums are
, , [1,3], which form possible sums of:
1, 3, 4.
Now if we add/patch
2to nums, the combinations are:
, , , [1,3], [2,3], [1,2,3].
Possible sums are
1, 2, 3, 4, 5, 6, which now covers the range
So we only need
博主大清早在被窝里看看手机，浏览下博客，发现 Error establishing a database connection，显然是数据库挂了= =|||
貌似就是作死直接LAMP的下场（linux + apache +mysql + php）
站点自从开启 https 之后 ，百度分享就不能用了！但是又寻找不到类似百度分享的替代品。。
- apache ssl配置
leetcode Longest Increasing Path in a Matrix
Given an integer matrix, find the length of the longest increasing path.
From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of the boundary (i.e. wrap-around is not allowed).
nums = [
The longest increasing path is
[1, 2, 6, 9].
leetcode Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.
You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.
The relative order inside both the even and odd groups should remain as it was in the input.
The first node is considered odd, the second node even and so on …
Lowest Common Ancestor of a Binary Tree 问题描述
Given a binary tree, find the lowest common ancestor of two given nodes in the tree.
leetcode Count of Range Sum
Given an integer array
nums, return the number of range sums that lie in
S(i, j)is defined as the sum of the elements in
A naive algorithm of O(n2) is trivial. You MUST do better than that.
Given nums =
[-2, 5, -1], lower =
-2, upper =
The three ranges are :
[0, 2]and their respective sums are:
-2, -1, 2.
leetcode Power of Three
Given an integer, write a function to determine if it is a power of three.
Could you do it without using any loop / recursion?