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

随笔分类 -  Leetcode

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 32 下一页
Leetcode: Zigzag Iterator

摘要:Best Solution: O(N) This solution also works for K vectors Use a queue to store the iterators in different vectors. Every time we call next(), we pop 阅读全文
posted @ 2015-12-26 08:11 neverlandly 阅读(355) 评论(0) 推荐(0)
Leetcode: Wiggle Sort

摘要:Given an unsorted array nums, reorder it in-place such that nums[0] = nums[2] = nums[i - 1]如果i是偶数,nums[i] nums[i - 1], 则交换以后肯定有nums[i] =nums[i-1])) {... 阅读全文
posted @ 2015-12-26 07:38 neverlandly 阅读(301) 评论(0) 推荐(0)
Leetcode: Perfect Squares

摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, ... 阅读全文
posted @ 2015-12-26 04:57 neverlandly 阅读(262) 评论(0) 推荐(0)
Leetcode: First Bad Version

摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c... 阅读全文
posted @ 2015-12-26 02:43 neverlandly 阅读(243) 评论(0) 推荐(0)
Leetcode: Find the Celebrity

摘要:最佳做法:O(N)time, O(1)space The first pass is to pick out the candidate. If candidate knows i, then switch candidate. The second pass is to check whether 阅读全文
posted @ 2015-12-26 01:46 neverlandly 阅读(380) 评论(0) 推荐(0)
Leetcode: Integer to English Words

摘要:Career Cup 150 Pg 442 Think of Convert(19,323,984) = Process(19) + "million" + Process(323) + "thousand" + Process(984) + "" The Process is a process 阅读全文
posted @ 2015-12-26 00:08 neverlandly 阅读(379) 评论(0) 推荐(0)
Leetcode: Paint Fence

摘要:There is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adjacent f... 阅读全文
posted @ 2015-12-25 05:59 neverlandly 阅读(789) 评论(0) 推荐(0)
Leetcode: H-Index II

摘要:Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm? Hint: Expected runtime complexity 阅读全文
posted @ 2015-12-25 03:10 neverlandly 阅读(434) 评论(0) 推荐(0)
Leetcode: H-Index

摘要:Hint: Sort first then scan: O(NlogN) time, O(1)space use another array: O(N) time, O(N) space(有点像counting sort) 我们额外使用一个大小为N+1的数组stats。stats[i]表示有多少文章 阅读全文
posted @ 2015-12-25 01:16 neverlandly 阅读(347) 评论(0) 推荐(0)
Leetcode: Closest Binary Search Tree Value II

摘要:Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target.Note:Given target value is a floating... 阅读全文
posted @ 2015-12-24 13:14 neverlandly 阅读(328) 评论(0) 推荐(0)
Leetcode: Encode and Decode Strings

摘要:If I choose / as spliter, how to ensure the other / wouldn't be seen as spliter? The idea is to store length of the str This one will be encoded as "6 阅读全文
posted @ 2015-12-24 12:27 neverlandly 阅读(455) 评论(0) 推荐(0)
Leetcode: Closest Binary Search Tree Value

摘要:Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.Note:Given target value is a floating... 阅读全文
posted @ 2015-12-24 09:47 neverlandly 阅读(298) 评论(0) 推荐(0)
Leetcode: Missing Number

摘要:Best Solution: Bit manipulation The basic idea is to use XOR operation. We all know that a^b^b =a, which means two xor operations with the same number 阅读全文
posted @ 2015-12-24 08:50 neverlandly 阅读(279) 评论(0) 推荐(0)
Leetcode: Graph Valid Tree && Summary: Detect cycle in undirected graph

摘要:This problem can be solved by using union find, reference this blog:https://segmentfault.com/a/1190000003791051 复杂度 时间 O(N^M) 空间 O(N) 思路 判断输入的边是否能构成一个 阅读全文
posted @ 2015-12-24 02:58 neverlandly 阅读(1013) 评论(0) 推荐(0)
Leetcode: Paint House II

摘要:There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. Yo 阅读全文
posted @ 2015-12-23 13:31 neverlandly 阅读(993) 评论(0) 推荐(0)
Leetcode: Palindrome Permutation II

摘要:Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form... 阅读全文
posted @ 2015-12-23 12:53 neverlandly 阅读(348) 评论(0) 推荐(0)
Leetcode: Palindrome Permutation

摘要:Given a string, determine if a permutation of the string could form a palindrome.For example,"code" -> False, "aab" -> True, "carerac" -> True.Hint:Co... 阅读全文
posted @ 2015-12-23 11:32 neverlandly 阅读(235) 评论(0) 推荐(0)
Leetcode: Ugly Number

摘要:Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exa 阅读全文
posted @ 2015-12-23 06:59 neverlandly 阅读(230) 评论(0) 推荐(0)
Leetcode: Ugly Number II

摘要:Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6... 阅读全文
posted @ 2015-12-23 06:48 neverlandly 阅读(277) 评论(0) 推荐(0)
Leetcode: Single Number III

摘要:Lintcode 也有这道题 Single Number III example: 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 如例所示,最后两个数8, 阅读全文
posted @ 2015-12-23 05:43 neverlandly 阅读(232) 评论(0) 推荐(0)

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 32 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3