• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅

随笔分类 -  Lintcode

上一页 1 2 3 4 下一页
Lintcode: O(1) Check Power of 2

摘要:Using O(1) time to check whether an integer n is a power of 2.ExampleFor n=4, return trueFor n=5, return falseChallengeO(1) timeTags Expand 这道题考察bit m... 阅读全文
posted @ 2015-04-02 05:24 neverlandly 阅读(575) 评论(0) 推荐(0)
Lintcode: Minimum Adjustment Cost

摘要:1 Given an integer array, adjust each integers so that the difference of every adjcent integers are not greater than a given number target.2 3 If the ... 阅读全文
posted @ 2015-04-02 04:56 neverlandly 阅读(1960) 评论(0) 推荐(0)
Lintcode: Nth to Last Node in List

摘要:Find the nth to last element of a singly linked list. The minimum number of nodes in list is n.ExampleGiven a List 3->2->1->5->null and n = 2, return... 阅读全文
posted @ 2015-04-02 03:40 neverlandly 阅读(553) 评论(0) 推荐(1)
Lintcode: Merge Sorted Array II

摘要:Merge two given sorted integer array A and B into a new sorted integer array.ExampleA=[1,2,3,4]B=[2,4,5,6]return [1,2,2,3,4,4,5,6]ChallengeHow can you... 阅读全文
posted @ 2015-03-16 04:41 neverlandly 阅读(599) 评论(0) 推荐(0)
Lintcode: Median

摘要:Given a unsorted array with integers, find the median of it. A median is the middle number of the array after it is sorted. If there are even numbers ... 阅读全文
posted @ 2015-03-16 03:56 neverlandly 阅读(1750) 评论(0) 推荐(0)
Lintcode: Maximum Subarray III

摘要:Given an array of integers and a number k, find k non-overlapping subarrays which have the largest sum.The number in each subarray should be contiguou... 阅读全文
posted @ 2015-03-14 10:53 neverlandly 阅读(466) 评论(0) 推荐(0)
Lintcode: Maximum Subarray II

摘要:Given an array of integers, find two non-overlapping subarrays which have the largest sum.The number in each subarray should be contiguous.Return the ... 阅读全文
posted @ 2015-03-14 05:49 neverlandly 阅读(476) 评论(0) 推荐(0)
Lintcode: 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.NoteThe ... 阅读全文
posted @ 2015-03-14 05:16 neverlandly 阅读(1206) 评论(0) 推荐(0)
Lintcode: Majority Number II

摘要:Given an array of integers, the majority number is the number that occurs more than 1/3 of the size of the array.Find it.NoteThere is only one majorit... 阅读全文
posted @ 2015-03-12 06:50 neverlandly 阅读(1238) 评论(0) 推荐(0)
Lintcode: Lowest Common Ancestor

摘要:Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.The lowest common ancestor is the node with large... 阅读全文
posted @ 2015-03-12 05:42 neverlandly 阅读(550) 评论(0) 推荐(0)
Lintcode: Longest Common Substring

摘要:Given two strings, find the longest common substring.Return the length of it.NoteThe characters in substring should occur continiously in original str... 阅读全文
posted @ 2015-03-09 11:33 neverlandly 阅读(447) 评论(0) 推荐(1)
Lintcode: Longest Common Subsequence

摘要:Given two strings, find the longest comment subsequence (LCS).Your code should return the length of LCS.ExampleFor "ABCD" and "EDCA", the LCS is "A" (... 阅读全文
posted @ 2015-03-09 08:11 neverlandly 阅读(735) 评论(0) 推荐(1)
Lintcode: Kth Prime Number (Original Name: Ugly Number)

摘要:Ugly number is a number that only have factors3,5and7.Design an algorithm to find the kth number such that the only prime factors are 3, 5, and 7.The ... 阅读全文
posted @ 2015-03-09 05:28 neverlandly 阅读(1531) 评论(0) 推荐(0)
Lintcode: Kth largest Element

摘要:Find K-th largest element in an array.NoteYou can swap elements in the arrayExampleIn array [9,3,2,4,8], the 3rd largest element is 4In array [1,2,3,4... 阅读全文
posted @ 2015-03-09 03:49 neverlandly 阅读(1613) 评论(0) 推荐(0)
Lintcode: k Sum

摘要:Given n distinct positive integers, integer k (k i) res[i][j][t] = 0;18 else res[i][j][t] = res[i-1][j][t];19 ... 阅读全文
posted @ 2015-03-07 05:22 neverlandly 阅读(542) 评论(0) 推荐(0)
Lintcode: k Sum II

摘要:Given n unique integers, number k (1> kSumII(int A[], int k, int target) { 9 // write your code here10 ArrayList> res = new ArrayList>... 阅读全文
posted @ 2015-03-05 06:51 neverlandly 阅读(1203) 评论(0) 推荐(0)
Lintcode: Interleaving Positive and Negative Numbers

摘要:Given an array with positive and negative integers. Re-range it to interleaving with positive and negative integers.NoteYou are not necessary to keep ... 阅读全文
posted @ 2015-03-05 06:14 neverlandly 阅读(1094) 评论(0) 推荐(1)
Lintcode: Insert Node in a Binary Search Tree

摘要:Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree.ExampleGi... 阅读全文
posted @ 2015-03-05 05:00 neverlandly 阅读(1260) 评论(0) 推荐(0)
Lintcode: Heapify && Summary: Heap

摘要:Heap的介绍1,介绍2,要注意complete tree和full tree的区别, Heap是complete tree;Heap里面 i 的 children分别是 i*2+1 和 i*2+2,i 的 parent是 (i-1)/2 Heapify的基本思路就是:Given an array 阅读全文
posted @ 2015-02-08 06:57 neverlandly 阅读(2041) 评论(0) 推荐(0)
Lintcode: Implement Queue by Stacks

摘要:As the title described, you should only use two stacks to implement a queue's actions.The queue should support push(element), pop() and top() where po... 阅读全文
posted @ 2015-02-07 07:51 neverlandly 阅读(444) 评论(0) 推荐(1)

上一页 1 2 3 4 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3