Fork me on GitHub
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 37 下一页
摘要: 题意大概是: 一个数比如242,把所有数字分成两组,而且两组的和相等,那么这个数就是神奇数,此时242,能够分成{2,2}和{4},所以242是神奇数。 题目要求输入n和m求[n,m]区间内神奇数的个数。 思路: 对于任意一个数字,将每一位上的数字保存到数组里,并求所有位上的数字的和sum。然后使用 阅读全文
posted @ 2017-09-08 22:51 hellowOOOrld 阅读(656) 评论(0) 推荐(0) 编辑
摘要: Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文
posted @ 2017-09-04 14:23 hellowOOOrld 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get. 阅读全文
posted @ 2017-09-03 12:40 hellowOOOrld 阅读(681) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might 阅读全文
posted @ 2017-09-03 11:54 hellowOOOrld 阅读(521) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. 阅读全文
posted @ 2017-09-03 11:32 hellowOOOrld 阅读(269) 评论(0) 推荐(0) 编辑
摘要: Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requ 阅读全文
posted @ 2017-09-01 22:27 hellowOOOrld 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 题意大概是给定M×N的棋盘格,从左上到右下,只能向右或者向下走,每走一步需要加上棋盘格子内的数值(有正有负)。 需要随时保证当前的数值>=1。问初始需要最少的值是多少? 思路: 动态规划。用dp[i][j]代表当前最大的数值。首先求出dp[m][n],得出到达右下角的最优值。 然后再回溯求出从左上角 阅读全文
posted @ 2017-08-27 22:27 hellowOOOrld 阅读(722) 评论(1) 推荐(0) 编辑
摘要: If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-digits integers. For each integer in this list: Given a 阅读全文
posted @ 2017-08-27 12:55 hellowOOOrld 阅读(567) 评论(0) 推荐(0) 编辑
摘要: Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element. We define an array is non-decr 阅读全文
posted @ 2017-08-27 11:33 hellowOOOrld 阅读(573) 评论(0) 推荐(0) 编辑
摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam 阅读全文
posted @ 2017-08-26 17:28 hellowOOOrld 阅读(155) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 37 下一页