• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页
2015年12月17日
Leetcode: House Robber II
摘要: Analysis: if the last one is not robbed, then you are free to choose whether to rob the first one. you can break the circle by assuming the first hous 阅读全文
posted @ 2015-12-17 12:20 neverlandly 阅读(337) 评论(0) 推荐(0)
Leetcode: Contains Duplicate II
摘要: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the ... 阅读全文
posted @ 2015-12-17 07:44 neverlandly 阅读(198) 评论(0) 推荐(0)
Leetcode: Kth Largest Element in an Array
摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For examp... 阅读全文
posted @ 2015-12-17 07:30 neverlandly 阅读(347) 评论(0) 推荐(0)
Leetcode: Contains Duplicate
摘要: Use HashSet: 阅读全文
posted @ 2015-12-17 07:01 neverlandly 阅读(198) 评论(0) 推荐(0)
Leetcode: Minimum Size Subarray Sum
摘要: Haven't think about the O(nlogn) solution. O(n) solution is to maintain a window My solution: shrink as much as possible while maintaining the window 阅读全文
posted @ 2015-12-17 06:52 neverlandly 阅读(289) 评论(0) 推荐(0)
Leetcode: Add and Search Word - Data structure design
摘要: 方法1:brute force: search function compares each word with the pattern, time complexity: O(nk), n is number of words in dictionary, k is averge length 方 阅读全文
posted @ 2015-12-17 06:46 neverlandly 阅读(619) 评论(0) 推荐(0)
2015年12月16日
Leetcode: Implement Trie (Prefix Tree) && Summary: Trie
摘要: 参考百度百科:Trie树 a trie, also called digital tree and sometimes radix tree or prefix tree (as they can be searched by prefixes) The time complexity to ins 阅读全文
posted @ 2015-12-16 13:45 neverlandly 阅读(529) 评论(0) 推荐(0)
Leetcode: Course Schedule II
摘要: There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have t 阅读全文
posted @ 2015-12-16 12:25 neverlandly 阅读(325) 评论(0) 推荐(0)
Leetcode: Course Schedule
摘要: The hint provided by leetcode is: Hints: BFS: 典型的拓扑排序。原理也很简单,在一个有向图中,每次找到一个没有前驱节点的节点(也就是入度为0的节点),然后把它指向其他节点的边都去掉,重复这个过程(BFS),直到所有节点已被找到,或者没有符合条件的节点(如果 阅读全文
posted @ 2015-12-16 11:18 neverlandly 阅读(311) 评论(0) 推荐(0)
2015年12月15日
Leetcode: Isomorphic Strings
摘要: Best: O(N) time, constant space 复杂度 时间 O(N) 空间 O(N) 思路 用一个哈希表记录字符串s中字母到字符串t中字母的映射关系,一个集合记录已经映射过的字母。或者用两个哈希表记录双向的映射关系。这里不能只用一个哈希表,因为要排除egg->ddd这种多对一的映射 阅读全文
posted @ 2015-12-15 11:46 neverlandly 阅读(333) 评论(0) 推荐(0)
Leetcode: Reverse Linked List
摘要: 基本迭代 Time: O(N), Space: O(1) 基本递归 Time: O(N), Space: O(N)递归栈大小 阅读全文
posted @ 2015-12-15 11:15 neverlandly 阅读(267) 评论(0) 推荐(0)
Leetcode: Count Primes
摘要: Count the number of prime numbers less than a non-negative number, n.Algorithm: The sieve of Eratosthenes,Referring to Summary: Primes0 and 1 are not ... 阅读全文
posted @ 2015-12-15 03:09 neverlandly 阅读(276) 评论(0) 推荐(0)
Leetcode: Remove Linked List Elements
摘要: set Dummy node 这题有个重要的follow up,就是在一个环里怎么删除节点: 参考:http://www.cnblogs.com/EdwardLiu/p/5975748.html 阅读全文
posted @ 2015-12-15 02:24 neverlandly 阅读(268) 评论(0) 推荐(0)
Leetcode: Bitwise AND of Numbers Range
摘要: Given a range [m, n] where 0 maxRange) continue; 9 int mi = (m>>i) & 1;10 int ni = (n>>i) & 1;11 if (mi == 1 && n... 阅读全文
posted @ 2015-12-15 02:14 neverlandly 阅读(217) 评论(0) 推荐(0)
Leetcode: Happy Number
摘要: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege 阅读全文
posted @ 2015-12-15 00:53 neverlandly 阅读(315) 评论(0) 推荐(0)
2015年9月2日
Latex技巧
摘要: 文件.tex 文件打开 error reading版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://www.blogbus.com/jzhao-logs/272261360.html现在从网上下载的.tex文件或从另一台机器copy过来的.tex文件,打开显示 error... 阅读全文
posted @ 2015-09-02 09:44 neverlandly 阅读(350) 评论(0) 推荐(0)
2015年4月21日
Lintcode: Singleton && Summary: Synchronization and OOD
摘要: Singleton is a most widely used design pattern. If a class has and only has one instance at every moment, we call this design as singleton. For exampl... 阅读全文
posted @ 2015-04-21 04:28 neverlandly 阅读(1829) 评论(0) 推荐(1)
2015年4月16日
Lintcode: Topological Sorting
摘要: 这道题参考了网上一些很好的思路: method1: Record the pre nodes of every node, then find out a node without pre node in each iteration and delete this node from unvisi 阅读全文
posted @ 2015-04-16 12:29 neverlandly 阅读(1054) 评论(0) 推荐(0)
2015年4月15日
Lintcode: Rotate String
摘要: Given a string and an offset, rotate string by offset. (rotate from left to right)ExampleGiven "abcdefg"for offset=0, return "abcdefg"for offset=1, re... 阅读全文
posted @ 2015-04-15 05:44 neverlandly 阅读(1458) 评论(0) 推荐(0)
Lintcode: Two Strings Are Anagrams
摘要: Write a method anagram(s,t) to decide if two strings are anagrams or not.ExampleGiven s="abcd", t="dcab", return trueO(N)time, O(1) space 1 public cla... 阅读全文
posted @ 2015-04-15 04:08 neverlandly 阅读(950) 评论(0) 推荐(0)
2015年4月12日
Leetcode: House Robber
摘要: This particular problem and most of others can be approached using the following sequence: https://leetcode.com/problems/house-robber/discuss/156523/F 阅读全文
posted @ 2015-04-12 03:36 neverlandly 阅读(590) 评论(0) 推荐(0)
2015年4月11日
Leetcode: Binary Tree Right Side View
摘要: 这道题就是BT的Level Order Traversal,每次要换一层的时候,记录当前节点 注意,每次都是先添加右边child,所以是i==0的时候add 阅读全文
posted @ 2015-04-11 07:06 neverlandly 阅读(789) 评论(0) 推荐(0)
Leetcode: Number of Islands
摘要: DFS的Flood Fill方法, 不使用额外visited数组,但是用‘1’变成‘2’表示visited的方法 复杂度 时间 O(NM) 空间 O(max(N,M)) 递归栈空间 Union Find: (Quick Union) follow up是找最大岛的面积,想法是设置两个全局变量 max 阅读全文
posted @ 2015-04-11 05:20 neverlandly 阅读(2351) 评论(0) 推荐(0)
2015年4月6日
Lintcode: 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 l... 阅读全文
posted @ 2015-04-06 12:48 neverlandly 阅读(640) 评论(1) 推荐(0)
Lintcode: Sort Letters by Case
摘要: Given a string which contains only letters. Sort it by lower case first and upper case second.NoteIt's not necessary to keep the original order of low... 阅读全文
posted @ 2015-04-06 09:31 neverlandly 阅读(1086) 评论(0) 推荐(0)
Lintcode: Sort Colors II
摘要: Given an array of n objects with k different colors (numbered from 1 to k), sort them so that objects of the same color are adjacent, with the colors ... 阅读全文
posted @ 2015-04-06 09:11 neverlandly 阅读(706) 评论(0) 推荐(0)
2015年4月4日
Lintcode: Single Number III
摘要: Given 2*n + 2 numbers, every numbers occurs twice except two, find them.ExampleGiven [1,2,2,3,4,4,5,3] return 1 and 5ChallengeO(n) time, O(1) extra sp... 阅读全文
posted @ 2015-04-04 04:59 neverlandly 阅读(2521) 评论(0) 推荐(0)
Lintcode: Search Range in Binary Search Tree
摘要: Given two values k1 and k2 (where k1 k1, 如果否,则不需要继续向左递归;右子树的处理方法类似第一次做法,把result数组作为return type,不好,消耗额外空间 1 public class Solution { 2 /** 3 *... 阅读全文
posted @ 2015-04-04 03:39 neverlandly 阅读(1229) 评论(0) 推荐(0)
Lintcode: Binary Tree Serialization (Serialization and Deserialization Of Binary Tree)
摘要: 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 f... 阅读全文
posted @ 2015-04-04 02:59 neverlandly 阅读(1005) 评论(0) 推荐(0)
2015年4月2日
Lintcode: Search a 2D matrix II
摘要: Write an efficient algorithm that searches for a value in an m x n matrix, return the occurrence of it.This matrix has the following properties: * ... 阅读全文
posted @ 2015-04-02 12:26 neverlandly 阅读(2222) 评论(0) 推荐(0)
Lintcode: Rehashing
摘要: The size of the hash table is not determinate at the very beginning. If the total size of keys is too large (e.g. size >= capacity / 10), we should do... 阅读全文
posted @ 2015-04-02 11:13 neverlandly 阅读(850) 评论(0) 推荐(0)
Lintcode: Recover Rotated Sorted Array
摘要: Given a rotated sorted array, recover it to sorted array in-place.Example[4, 5, 1, 2, 3] -> [1, 2, 3, 4, 5]ChallengeIn-place, O(1) extra space and O(n... 阅读全文
posted @ 2015-04-02 10:33 neverlandly 阅读(1366) 评论(0) 推荐(0)
Lintcode: Product of Array Exclude Itself
摘要: Given an integers array A.Define B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], calculate B without divide operation.ExampleFor A=[1, 2, 3], B is... 阅读全文
posted @ 2015-04-02 09:59 neverlandly 阅读(1932) 评论(0) 推荐(0)
Lintcode: Previous Permuation
摘要: Given a list of integers, which denote a permutation.Find the previous permutation in ascending order.NoteThe list may contains duplicate integers.Exa... 阅读全文
posted @ 2015-04-02 07:01 neverlandly 阅读(1212) 评论(0) 推荐(0)
Lintcode: Partition Array
摘要: Given an array "nums" of integers and an int "k", Partition the array (i.e move the elements in "nums") such that, * All elements = k are moved to ... 阅读全文
posted @ 2015-04-02 06:21 neverlandly 阅读(1702) 评论(0) 推荐(0)
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 阅读(1961) 评论(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)
2015年4月1日
Summary: Trie Data Structure
摘要: Implement a Trie Data Structure, and search() & insert() function: we need to implement both Class Trie and Class TrieNode Class Trie: Class TrieNode: 阅读全文
posted @ 2015-04-01 11:29 neverlandly 阅读(369) 评论(0) 推荐(0)
2015年3月22日
CareerCup: 17.14 minimize unrecognized characters
摘要: Oh, no! You have just completed a lengthy document when you have an unfortu-nate Find/Replace mishap. You have accidentally removed all spaces, p... 阅读全文
posted @ 2015-03-22 11:55 neverlandly 阅读(749) 评论(0) 推荐(0)
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3