E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
lintCode
Sqrt(x) -
LintCode
examination questions Implement int sqrt(int x). Compute and return the square root of x. Example sqrt(3) = 1 sqrt(4) = 2 sqrt(5) = 2 sqrt(10) = 3 Challenge O(log(x)) 解题代码 class Solu
·
2015-10-31 11:01
code
lintcode
-滑动窗口的最大值
给出一个可能包含重复的整数数组,和一个大小为k的滑动窗口,从左到右在数组中滑动这个窗口,找到数组中每个窗口内的最大值。样例给出数组[1,2,7,7,8],滑动窗口大小为k=3.返回[7,7,8].解释:最开始,窗口的状态如下:[|1,2,7|,7,8],最大值为7;然后窗口向右移动一位:[1,|2,7,7|,8],最大值为7;最后窗口再向右移动一位:[1,2,|7,7,8|],最大值为8.挑战O(
ljlstart
·
2015-10-29 20:00
5.2 Binary to String
/ofractiontobinaryanddecimalw/fractiontobinary.Asimilarbutalittlebitmorecomplexproblemcanbefoundfrom
lintCode
u012175043
·
2015-10-29 06:00
BitMani
二分查找与旋转排序数组 算法题
一.二分搜索(BinarySearch)模板及其理解1.通用模板,解决start,end,mid,(>=)等问题http://www.
lintcode
.com/en/problem/binary-search
wangxiaobao1114
·
2015-10-27 22:00
[
LintCode
] Longest Increasing Continuous subsequence II
Longest Increasing Continuous subsequence II Give you an integer matrix (with row size n, column size m),find the longest increasing continuous subsequence in this matrix. (The definition of the lo
·
2015-10-27 15:33
sequence
[
LintCode
] Maximum Subarray Difference
Maximum Subarray Difference Given an array with integers. Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is the largest. Return the largest difference.
·
2015-10-27 15:32
array
[
LintCode
] Max Tree
Max Tree Given an integer array with no duplicates. A max tree building on this array is defined as follow: The root is the maximum number in the array The left subtree and right subtree are t
·
2015-10-27 15:31
code
[
LintCode
] Count of Smaller Number before itself
Count of Smaller Number before itself Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 10000) . For each element Ai in the array, count the
·
2015-10-27 15:31
BEFORE
[
LintCode
] Maximum Subarray III
Maximum Subarray III Given an array of integers and a number k, find knon-overlapping subarrays which have the largest sum. The number in each subarray should be contiguous. Return t
·
2015-10-27 15:30
array
[
LintCode
] Subarray Sum & Subarray Sum II
Subarray Sum Given an integer array, find a subarray where the sum of numbers is zero. Your code should return the index of the first number and the index of the last number. Example Given
·
2015-10-27 15:29
array
[
LintCode
] Minimum Adjustment Cost
Minimum Adjustment Cost Given an integer array, adjust each integers so that the difference of every adjacent integers are not greater than a given number target. If the array before adjustment
·
2015-10-27 15:29
code
[
LintCode
] Binary Tree Serialization
Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back from the file to reconstruct the exact same binary
·
2015-10-27 15:27
serialization
[
LintCode
] Coins in a Line II
There are n coins with different value in a line. Two players take turns to take one or two coins from left side until there are no more coins left. The player who take the coins with the most value w
·
2015-10-27 15:26
code
[
LintCode
] k Sum
Given n distinct positive integers, integer k (k <= n) and a number target. Find k numbers where sum is target. Calculate how many solutions there are? Example Given [1,2,3,4], k=2, target=5.&
·
2015-10-27 15:25
code
[
LintCode
] Find Peak Element II
There is an integer matrix which has the following features: The numbers in adjacent positions are different. The matrix has n rows and m columns. For all i < m, A[0][i] < A[1][i] &
·
2015-10-27 15:25
element
[
LintCode
] Delete Digits
Given string A representative a positive integer which has N digits, remove any k digits of the number, the remaining digits are arranged according to the original order to become
·
2015-10-27 15:24
delete
[
LintCode
] Number of Airplanes in the Sky
Given an interval list which are flying and landing time of the flight. How many airplanes are on the sky at most? Example For interval list [[1,10],[2,3],[5,8],[4,7]], return 3 No
·
2015-10-27 15:24
number
[
LintCode
] Subarray Sum Closest
Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number. Example Given [-3, 1, 1, -3, 5], return [0, 2], [1, 3], [1, 1], [2, 2] or
·
2015-10-27 15:23
array
LintCode
: 加一
LintCode
:加一给定一个非负数,表示一个数字数组,在该数的基础上+1,返回一个新的数组。该数字按照大小进行排列,最大的数在列表的最前面。
u012225151
·
2015-10-26 21:00
lintcode
LintCode
: 有效回文串
LintCode
:有效回文串给定一个字符串,判断其是否为一个回文串。只包含字母和数字,忽略大小写。
u012225151
·
2015-10-26 17:00
lintcode
LintCode
: Maximal Square
#
LintCode
:MaximalSquareGivena2Dbinarymatrixfilledwith0’sand1’s,findthelargestsquarecontainingall1’sandreturnitsarea
u012225151
·
2015-10-26 16:00
有效的括号序列(
LintCode
)
题目来源:
LintCode
原题地址:http://www.
lintcode
.com/zh-cn/problem/valid-parentheses/题目:给定一个字符串所表示的括号序列,包含以下字符:'
ucas卢阳云
·
2015-10-25 14:52
算法
LintCode
lintcode
-用递归打印数字
递归的方法找到从1到最大的N位整数。 样例给出N=1,返回[1,2,3,4,5,6,7,8,9].给出N=2,返回[1,2,3,4,5,6,7,8,9,10,11,...,99].注意用下面这种方式去递归其实很容易:recursion(i){ ifi>largestnumber: return results.add(i) recursion(i+1) } 但是这种方式会耗费很多的递归空间,导致堆
ljlstart
·
2015-10-24 23:00
lintcode
-赋值运算符重载
实现赋值运算符重载函数,确保:新的数据可准确地被复制旧的数据可准确地删除/释放可进行A=B=C赋值样例如果进行A=B赋值,则A中的数据被删除,取而代之的是B中的数据。如果进行A=B=C赋值,则A和B都复制了C中的数据。挑战充分考虑安全问题,并注意释放旧数据。说明本题只适用于C++,因为Java和Python没有对赋值运算符的重载机制。classSolution{ public: char*m_pD
ljlstart
·
2015-10-24 23:00
lintcode
- N皇后问题
n皇后问题是将n个皇后放置在n*n的棋盘上,皇后彼此之间不能相互攻击。给定一个整数n,返回所有不同的n皇后问题的解决方案。每个解决方案包含一个明确的n皇后放置布局,其中“Q”和“.”分别表示一个女王和一个空位置。样例对于4皇后问题存在两种解决的方案:[ [".Q..",//Solution1 "...Q", "Q...", "..Q."], ["..Q.",//Solution2
ljlstart
·
2015-10-24 21:00
lintcode
-N皇后问题II
n皇后问题是将n个皇后放置在n*n的棋盘上,皇后彼此之间不能相互攻击。给定一个整数n,求n皇后问题的有多少种解决方案classSolution{ voidsearch(vector&c,intn,intcur,int&ret){ if(cur==n){ ++ret; return; } for(inti=0;i&c,introw,intcol){ for(inti=0;ic(n); intret=
ljlstart
·
2015-10-24 20:00
[
LintCode
] Remove Node in Binary Search Tree
Remove Node in Binary Search Tree Given a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in the binary
·
2015-10-23 08:20
Binary search
[
LintCode
] Find the Weak Connected Component in the Directed Graph
Find the Weak Connected Component in the Directed Graph Find the number Weak Connected Component in the directed graph. Each node in the graph contains a label and a list of its neighbors. (a connect
·
2015-10-23 08:19
component
[
LintCode
] Find the Connected Component in the Undirected Graph
Find the Connected Component in the Undirected Graph Find the number connected component in the undirected graph. Each node in the graph contains a label and a list of its neighbors. (a connected com
·
2015-10-23 08:19
component
lintcode
-最长回文子串-200
给出一个字符串(假设长度最长为1000),求出它的最长回文子串,你可以假定只有一个满足条件的最长回文串。样例给出字符串"abcdzdcab",它的最长回文子串为"cdzdc"。挑战O(n2)时间复杂度的算法是可以接受的,如果你能用O(n)的算法那自然更好classSolution{ public: stringlongestPalindrome(string&s){ if(s.empty())
ljlstart
·
2015-10-23 01:00
lintcode
-排序列表转换为二分查找树-106
/** *DefinitionofListNode *classListNode{ *public: *intval; *ListNode*next; *ListNode(intval){ *this->val=val; *this->next=NULL; *} *} *DefinitionofTreeNode: *classTreeNode{ *public: *intval; *TreeNod
ljlstart
·
2015-10-21 22:00
LintCode
-- Remove Linked List Elements
Removeallelementsfromalinkedlistofintegersthathavevalueval.样例Given 1->2->3->3->4->5->3,val=3,youshouldreturnthelistas1->2->4->5 /** *Definitionforsingly-linkedlist. *publicclassListNode{ *intval;
feiling
·
2015-10-21 21:00
lintcode
- Flatten Binary Tree to Linked List-453
Flattenabinarytreetoafake"linkedlist"inpre-ordertraversal.HereweusetherightpointerinTreeNodeasthenextpointerinListNode.样例1 \ 12 /\\ 25=>3 /\\\ 3464 \ 5 \ 6 注意Don'tforgettomarktheleftchildofeachnodeton
ljlstart
·
2015-10-21 21:00
[
LintCode
] N-Queens
N-Queens The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queen
·
2015-10-21 12:20
code
LintCode
-最大数
分享代码~boolcmp(stringa,stringb){if(a+b>b+a)returntrue;elsereturnfalse;}classSolution{public:/***@paramnum:Alistofnonnegativeintegers*@return:Astring*/stringtoString(intx){if(x==0){return"0";}strings="";
cjf478
·
2015-10-20 21:13
Binary Representation
BinaryRepresentation今天还是一道有关数学计算的题目,BinaryRepresentation,来自
LintCode
,难度为Hard,Acceptance为19%。
ab409
·
2015-10-20 18:55
lintcode
-Candy-412
有 N 个小孩站成一列。每个小孩有一个评级。按照以下要求,给小孩分糖果:每个小孩至少得到一颗糖果。评级越高的小孩可以得到更多的糖果。需最少准备多少糖果?样例给定评级= [1,2],返回 3.给定评级= [1,1,1],返回 3.给定评级= [1,2,2],返回 4.([1,2,1]).标签 Expand 分析:其实题目描述的有点问题,不是评级越高的小孩可以得到更多的糖果,从第三个样例中可以看出来
ljlstart
·
2015-10-19 22:00
lintcode
-合并k个排序链表-104
合并k个排序链表,并且返回合并后的排序链表。尝试分析和描述其复杂度。样例给出3个排序链表[2->4->null,null,-1->null],返回 -1->2->4->null/** *DefinitionofListNode *classListNode{ *public: *intval; *ListNode*next; *ListNode(intval){ *this->val=val; *
ljlstart
·
2015-10-19 21:00
lintcode
-落单的数III-84
给出2*n+2个的数字,除其中两个数字之外其他每个数字均出现两次,找到这两个数字。样例给出[1,2,2,3,4,4,5,3],返回1和5挑战O(n)时间复杂度,O(1)的额外空间复杂度classSolution{ intgetbitposition(inta){ intnum=1; intcount=0; while((a&num)==0){ numsingleNumberIII(vector&A
ljlstart
·
2015-10-19 20:00
[
LintCode
] Longest Increasing Subsequence 最长递增子序列
Givenasequenceofintegers,findthelongestincreasingsubsequence(LIS).YoucodeshouldreturnthelengthoftheLIS.Haveyoumetthisquestioninarealinterview? ExampleFor[5,4,1,2,3],theLIS is[1,2,3],return3For[4,2,4
Grandyang
·
2015-10-19 12:00
lintcode
- 前序遍历和中序遍历树构造二叉树-73
/** *DefinitionofTreeNode: *classTreeNode{ *public: *intval; *TreeNode*left,*right; *TreeNode(intval){ *this->val=val; *this->left=this->right=NULL; *} *} */ classSolution{ public: TreeNode*buildTre
ljlstart
·
2015-10-19 01:00
lintcode
-中序遍历和后序遍历树构造二叉树-72
/** *DefinitionofTreeNode: *classTreeNode{ *public: *intval; *TreeNode*left,*right; *TreeNode(intval){ *this->val=val; *this->left=this->right=NULL; *} *} */ classSolution{ public: TreeNode*buildTree(
ljlstart
·
2015-10-19 00:00
lintcode
-Remove Linked List Elements-452
Removeallelementsfromalinkedlistofintegersthathavevalueval.样例Given1->2->3->3->4->5->3,val=3,youshouldreturnthelistas1->2->4->5classSolution{ public: ListNode*removeElements(ListNode*head,intval){ if(
ljlstart
·
2015-10-19 00:00
lintcode
-回文链表-223
设计一种方式检查一个链表是否为回文链表。样例1->2->1就是一个回文链表。挑战O(n)的时间和O(1)的额外空间。/** *Definitionforsingly-linkedlist. *structListNode{ *intval; *ListNode*next; *ListNode(intx):val(x),next(NULL){} *}; */ classSolution{ publi
ljlstart
·
2015-10-18 23:00
lintcode
-Swap Nodes in Pairs -451
Givenalinkedlist,swapeverytwoadjacentnodesandreturnitshead.样例Given1->2->3->4,youshouldreturnthelistas2->1->4->3.挑战Youralgorithmshoulduseonlyconstantspace.Youmaynotmodifythevaluesinthelist,onlynodesits
ljlstart
·
2015-10-18 21:00
lintcode
-买卖股票的最佳时机II-150
假设有一个数组,它的第i个元素是一个给定的股票在第i天的价格。设计一个算法来找到最大的利润。你可以完成尽可能多的交易(多次买卖股票)。然而,你不能同时参与多个交易(你必须在再次购买前出售股票)。样例给出一个数组样例[2,1,2,0,1],返回2貌似有点像贪心算法,其实也很好理解,拿只笔比划比划就懂了classSolution{ public: intmaxProfit(vector&prices
ljlstart
·
2015-10-15 21:00
lintcode
-买卖股票的最佳时机-149
假设有一个数组,它的第i个元素是一支给定的股票在第i天的价格。如果你最多只允许完成一次交易(例如,一次买卖股票),设计一个算法来找出最大利润。样例给出一个数组样例[3,2,3,1,2],返回1可以这道题转换成求数组中两个元素的最大差值(而且是右边的数减去左边的数)classSolution{ public: intmaxProfit(vector&prices){ if(prices.empty
ljlstart
·
2015-10-15 21:00
lintcode
-不同的二叉查找树-163
给出n,问由1...n为节点组成的不同的二叉查找树有多少种?您在真实的面试中是否遇到过这个题?样例给出n=3,有5种不同形态的二叉查找树:13321 \///\\ 321132 //\\ 2123 没有什么好办法,就是找规律Thecasefor3elementsexample Count[3]=Count[0]*Count[2](1asroot) +Count[1]*Count[1](2asroo
ljlstart
·
2015-10-15 21:00
lintcode
-表达式求值-368
给一个用字符串表示的表达式数组,求出这个表达式的值。样例对于表达式(2*6-(23+7)/(1+2)),对应的数组为:[ "2","*","6","-","(", "23","+","7",")","/", (","1","+","2",")" ], 其值为2注意表达式只包含整数,+,-,*,/,(,)解题思路: step1:把中缀表达式转换成后缀表达式 step2:通
ljlstart
·
2015-10-15 20:00
lintcode
-电话号码的字母组合-425
给一个数字字符串,每个数字代表一个字母,请返回其所有可能的字母组合。下图的手机按键图,就表示了每个数字可以代表的字母。样例给定"23"返回["ad","ae","af","bd","be","bf","cd","ce","cf"]classSolution{ public: voidinit(){ node['2'].push_back('a'); node['2'].push_back('b')
ljlstart
·
2015-10-15 20:00
上一页
75
76
77
78
79
80
81
82
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他