原创 Lintcode1 A+B Problem solution 題解

【題目描述】Write a function that add two numbers A and B. You should not use + or any arithmetic operators.Notice:There is no

原创 Lintcode2 Trailing Zeros solution 題解

【題目描述】Write an algorithm which computes the number of trailing zeros in n factorial.設計一個算法,計算出n階乘中尾部零的個數。【題目鏈接】http://ww

原创 Lintcode3 Digit Counts solution 題解

【題目描述】Count the number of k's between 0 and n. k can be 0 - 9.計算數字k在0到n中的出現的次數,k可能是0~9的一個值。【題目鏈接】http://www.lintcode.com

原创 Lintcode4 Ugly Number II solution 題解

【題目描述】Ugly number is a number that only have factors 2, 3 and 5.Design an algorithm to find the nth ugly number. The fir

原创 Lintcode15 Permutations solution 題解

【題目描述】Given a list of numbers, return all possible permutations.Notice:You can assume that there is no duplicate numbers

原创 Lintcode8 Rotate String solution 題解

【題目描述】Given a string and an offset, rotate string by offset. (rotate from left to right)給定一個字符串和一個偏移量,根據偏移量旋轉字符串(從左向右旋轉)

原创 Lintcode14 First Position of Target Solution 題解

【題目描述】For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) ti

原创 Lintcode9 Fizz Buzz solution 題解

【題目描述】Given number n. Print number from 1 to n. But:when number is divided by 3, print "fizz".when number is divided by

原创 Lintcode6 Merge Two Sorted Arrays solution 題解

【題目描述】Merge two given sorted integer array A and B into a new sorted integer array.合併兩個排序的整數數組A和B變成一個新的數組。【題目鏈接】http://w

原创 Lintcode7 Binary Tree Serialization solution 題解

【題目描述】Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is calle

原创 Lintcode24 LFU Cache solution 題解

【題目描述】LFU (Least Frequently Used) is a famous cache eviction algorithm.For a cache with capacity k, if the cache is full

原创 Lintcode12 Min Stack solution 題解

題目描述】Implement a stack with min() function, which will return the smallest number in the stack.It should support push, p

原创 Lintcode22 Flatten List solution 題解

【題目描述】Given a list, each element in the list can be a list or integer. flatten it into a simply list with integers.Notic

原创 Lintcode29 Interleaving String solution 題解

【題目描述】Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2.給出三個字符串:s1、s2、s3,

原创 Lintcode13 strStr solution 題解

【題目描述】For a given source string and a target string, you should output the first index(from 0) of target string in sourc