随笔分类 -  算法题

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 16 下一页
摘要:Description:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are s... 阅读全文
posted @ 2015-09-30 20:47 Pickle 阅读(236) 评论(0) 推荐(0)
摘要: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,... 阅读全文
posted @ 2015-09-30 19:03 Pickle 阅读(244) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2015-09-30 10:44 Pickle 阅读(205) 评论(0) 推荐(0)
摘要:Description:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each... 阅读全文
posted @ 2015-09-29 22:22 Pickle 阅读(156) 评论(0) 推荐(0)
摘要:Description:Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexcept... 阅读全文
posted @ 2015-09-29 17:49 Pickle 阅读(146) 评论(0) 推荐(0)
摘要:Description:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return... 阅读全文
posted @ 2015-09-28 23:06 Pickle 阅读(191) 评论(0) 推荐(0)
摘要:Description:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.n皇后问题:每两个皇后之间不能... 阅读全文
posted @ 2015-09-28 23:01 Pickle 阅读(326) 评论(0) 推荐(0)
摘要:Description:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?在不借助辅助空间的情况下判断一个链表是否存在回路。可以用两个... 阅读全文
posted @ 2015-09-28 17:27 Pickle 阅读(214) 评论(0) 推荐(0)
摘要:Description:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3retur... 阅读全文
posted @ 2015-09-28 00:23 Pickle 阅读(158) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2015-09-27 22:32 Pickle 阅读(138) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2015-09-27 17:17 Pickle 阅读(162) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2015-09-27 16:56 Pickle 阅读(136) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2015-09-26 22:18 Pickle 阅读(170) 评论(0) 推荐(0)
摘要:Description:Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For exa... 阅读全文
posted @ 2015-09-26 21:37 Pickle 阅读(161) 评论(0) 推荐(0)
摘要:Description:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, ... 阅读全文
posted @ 2015-09-26 21:05 Pickle 阅读(166) 评论(0) 推荐(0)
摘要:Description:Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process ... 阅读全文
posted @ 2015-08-20 21:49 Pickle 阅读(934) 评论(0) 推荐(1)
摘要:Description:Given acompletebinary tree, count the number of nodes.In a complete binary tree every level, except possibly the last, is completely fille... 阅读全文
posted @ 2015-08-13 23:29 Pickle 阅读(225) 评论(0) 推荐(0)
摘要:Description:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on... 阅读全文
posted @ 2015-08-13 00:50 Pickle 阅读(198) 评论(0) 推荐(0)
摘要:Description:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断一个单向链表是不是回文。思路:最简单的思路就... 阅读全文
posted @ 2015-08-13 00:29 Pickle 阅读(186) 评论(0) 推荐(0)
摘要:Description:Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = "anagram", t = "nagaram", return true. s... 阅读全文
posted @ 2015-08-04 00:09 Pickle 阅读(347) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 16 下一页