摘要: Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the differe... 阅读全文
posted @ 2015-08-18 09:29 李小橘er 阅读(164) 评论(0) 推荐(0)
摘要: Given an array of numbersnums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements t... 阅读全文
posted @ 2015-08-17 15:49 李小橘er 阅读(375) 评论(0) 推荐(0)
摘要: 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 may complete a... 阅读全文
posted @ 2015-08-17 13:09 李小橘er 阅读(165) 评论(0) 推荐(0)
摘要: 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 transaction (ie... 阅读全文
posted @ 2015-08-17 12:42 李小橘er 阅读(189) 评论(0) 推荐(0)
摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2015-08-17 11:18 李小橘er 阅读(182) 评论(0) 推荐(0)
摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
posted @ 2015-08-17 11:06 李小橘er 阅读(266) 评论(0) 推荐(0)
摘要: Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur... 阅读全文
posted @ 2015-08-17 10:40 李小橘er 阅读(237) 评论(0) 推荐(0)
摘要: Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3 + ... 阅读全文
posted @ 2015-08-17 09:41 李小橘er 阅读(317) 评论(0) 推荐(0)
摘要: 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 Wikipedia: ... 阅读全文
posted @ 2015-08-16 15:01 李小橘er 阅读(492) 评论(0) 推荐(0)
摘要: Given an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If there isn't one, return 0 i... 阅读全文
posted @ 2015-08-16 10:27 李小橘er 阅读(183) 评论(0) 推荐(0)