摘要: 操作数组方法: 阅读全文
posted @ 2017-08-21 15:30 stAr_1 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 问题1: 问题2: 问题3: 这次是可以交易任意次,但是每次卖出的时候都要收取一定费用,所以不能用贪心了,因为贪心只能考虑相邻的两个是否交易,但是这次可能出现前边的留着不卖而后边卖,要用常规的动态规划,但是状态法方程和动态变量都有两个 直接上代码 未完待续... 阅读全文
posted @ 2017-08-16 17:56 stAr_1 阅读(280) 评论(0) 推荐(0) 编辑
摘要: Given a triangle, find the minimum path sum from top to bottom.Each step you may move to adjacent numbers on the row below.For example, given the following triangle[[2],[3,4],[6,5,7],[4,1,8,3]]The min... 阅读全文
posted @ 2017-08-16 15:19 stAr_1 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 杨辉三角1Given 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]]构建杨辉三角,从第一行开始构建,比较简单 public List> generate(int numRow... 阅读全文
posted @ 2017-08-15 16:33 stAr_1 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 根据二叉树的前序遍历和中序 阅读全文
posted @ 2017-08-10 20:34 stAr_1 阅读(362) 评论(0) 推荐(0) 编辑
摘要: /** * Merge two sorted linked lists and return it as a new list. * The new list should be made by splicing together the nodes of the first two lists. *//*由于链表只能从前向后添加的特点,所以从前边开始比较,小的添加进去每次递归确定一个node,需... 阅读全文
posted @ 2017-08-09 18:01 stAr_1 阅读(148) 评论(0) 推荐(0) 编辑
摘要: /** * Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or ve... 阅读全文
posted @ 2017-08-04 17:54 stAr_1 阅读(238) 评论(0) 推荐(0) 编辑
摘要: import java.util.Arrays; /** * Given an array with n objects colored red,white or blue, * sort them so that objects of the same color are adjacent, * with the colors in the order red, white and ... 阅读全文
posted @ 2017-08-02 17:50 stAr_1 阅读(213) 评论(0) 推荐(0) 编辑
摘要: /** * Created by lvhao on 2017/8/1. * Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from l... 阅读全文
posted @ 2017-08-01 17:05 stAr_1 阅读(194) 评论(0) 推荐(0) 编辑
摘要: /** * Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution usi... 阅读全文
posted @ 2017-07-31 17:35 stAr_1 阅读(201) 评论(0) 推荐(0) 编辑