随笔分类 - Lintcode
Lintcode: Flip Bits
摘要:Determine the number of bits required to flip if you want to convert integer n to integer m.Have you met this question in a real interview? YesExample...
阅读全文
Lintcode: Subarray Sum Closest
摘要:Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number.Have you met this question in...
阅读全文
Lintcode: Remove Node in Binary Search Tree
摘要:iven a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in t...
阅读全文
Lintcode: Majority Number III
摘要:Given an array of integers and a number k, the majority number is the number that occurs more than 1/k of the size of the array.Find it.Have you met t...
阅读全文
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...
阅读全文
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
阅读全文
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...
阅读全文
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...
阅读全文
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...
阅读全文
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...
阅读全文
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 ...
阅读全文
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...
阅读全文
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 *...
阅读全文
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...
阅读全文
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: * ...
阅读全文
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...
阅读全文
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...
阅读全文
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...
阅读全文
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...
阅读全文
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 ...
阅读全文
浙公网安备 33010602011771号