• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
04 2015 档案
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 阅读(1830) 评论(0) 推荐(1)
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 阅读(1058) 评论(0) 推荐(0)
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 阅读(1461) 评论(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 阅读(955) 评论(0) 推荐(0)
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 阅读(592) 评论(0) 推荐(0)
Leetcode: Binary Tree Right Side View

摘要:这道题就是BT的Level Order Traversal,每次要换一层的时候,记录当前节点 注意,每次都是先添加右边child,所以是i==0的时候add 阅读全文
posted @ 2015-04-11 07:06 neverlandly 阅读(792) 评论(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 阅读(2354) 评论(0) 推荐(0)
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 阅读(642) 评论(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 阅读(1092) 评论(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 阅读(708) 评论(0) 推荐(0)
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 阅读(2525) 评论(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 阅读(1232) 评论(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 阅读(1008) 评论(0) 推荐(0)
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 阅读(2226) 评论(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 阅读(855) 评论(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 阅读(1368) 评论(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 阅读(1934) 评论(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 阅读(1215) 评论(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 阅读(1705) 评论(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 阅读(577) 评论(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 阅读(1963) 评论(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 阅读(557) 评论(0) 推荐(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 阅读(371) 评论(0) 推荐(0)

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3