摘要:
Description:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution se... 阅读全文
摘要:
Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You ma... 阅读全文
摘要:
Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You ma... 阅读全文
摘要:
Description:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one tra... 阅读全文
摘要:
Description:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum e... 阅读全文
摘要:
Mahout中对协同过滤算法进行了封装,看一个简单的基于用户的协同过滤算法。基于用户:通过用户对物品的偏好程度来计算出用户的在喜好上的近邻,从而根据近邻的喜好推测出用户的喜好并推荐。图片来源程序中用到的数据都存在MySQL数据库中,计算结果也存在MySQL中的对应用户表中。package com.m... 阅读全文
摘要:
最近在一个项目中需要对文件进行自动的解压缩,Java提供了这种支持,还是挺好用的。工具包封装在java.util.zip中。1.首先是多个文件压缩成一个ZIP文件思路:用一个ZipOutputStream包装一个目的ZIP文件--->遍历文件数组:对每一个文件创建一个ZipEntry并put进Zip... 阅读全文
摘要:
Description:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.给一个升序有序的数组,构建一个平衡的二叉查找树。要平衡就要找中间的数来做头结点,递... 阅读全文
摘要:
Description:Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0... 阅读全文
摘要:
Description:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.noting to say.public class Solut... 阅读全文
摘要:
Description:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and o... 阅读全文
摘要:
Description:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are s... 阅读全文
摘要:
Description:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,... 阅读全文
摘要:
Description:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were in... 阅读全文
摘要:
Description:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each... 阅读全文
摘要:
常见的前序、中序、后序都很常见,最近用到了按层遍历,记录一下:思路:用一个队列来作为辅助空间。依次存储头结点,左节点和右节点。每次循环输出节点的值,直到队列为空这样一来就利用了队列先进先出的性质实现了非递归按层遍历二叉树。具体实现:void levelOrderTraverse(const BiTr... 阅读全文
摘要:
Description:Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexcept... 阅读全文
摘要:
Description:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return... 阅读全文
摘要:
Description:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.n皇后问题:每两个皇后之间不能... 阅读全文
摘要:
Description:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?在不借助辅助空间的情况下判断一个链表是否存在回路。可以用两个... 阅读全文
摘要:
Description:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3retur... 阅读全文
摘要:
Description:Given an array of numbersnums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the tw... 阅读全文
摘要:
Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You ma... 阅读全文
摘要:
Description:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf pat... 阅读全文
摘要:
Description:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails t... 阅读全文