随笔分类 - Lintcode刷题笔记
摘要:标签: 动态规划 描述: Find the contiguous subarray within an array (containing at least one number) which has the largest product. Find the contiguous subarray
阅读全文
摘要:标签: 动态规划 解题思路 1. 这道题最重要的是,存在三个字符串,但是并不需要两个二维矩阵来进行解,因为可以使用i+j-1来代表s3的下标,这样就可以通过i和j来遍历s3了。因为对于任何一个合法的交叉字符串都会有,s3(i+j-1)=s1(i-1) 或者s3(i+j-1) = s2(j-1) 2.
阅读全文
摘要:标签:动态规划 描述: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step
阅读全文
摘要:标签:动态规划 题目描述: Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is
阅读全文
摘要:标签: 动态规划 问题描述: There are n coins with different value in a line. Two players take turns to take one or two coins from left side until there are no mor
阅读全文
摘要:标签: 动态规划 描述: Given an integer array nums with all positive numbers and no duplicates, find the number of possible combinations that add up to a positi
阅读全文
摘要:标签:动态规划 问题描述: Given n items with size Ai and value Vi, and a backpack with size m. What's the maximum value can you put into the backpack? 解题思路: 又是一道恶
阅读全文
摘要:标记: 动态规划 问题描述: Given n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack? Example If we have 4 item
阅读全文
摘要:标签:动态规划 题目描述: Given two strings, find the longest common subsequence (LCS). Your code should return the length of LCS. 解题思路: 这一题是非常经典的动态规划问题,在解题思路上可以按
阅读全文
摘要:标签: 位运算 描述: Given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e g , M
阅读全文
摘要:标签: 位运算 描述 Write a function that add two numbers A and B. You should not use + or any arithmetic operators. 解题思路: 利用位运算来解决A+B的问题,可以将此问题转化为解决不进位相加和进位(c
阅读全文
摘要:标签: 位运算 描述: Count how many 1 in binary representation of a 32-bit integer. 解题思路: 统计一个int型的数的二进制表现形式中1的个数1.与check power of 2中的解题形式非常相似,同样利用num&(num-1)
阅读全文
摘要:标签: 位运算 题目: Using O(1) time to check whether an integer n is a power of 2. 解题思路: 这道题是利用位运算判断一个数是不是2 的整数次方思路:1. 如果一个数是2的整数次方的话,那么他的二进制表现形式上只有一位是1,其余的都会
阅读全文
摘要:Flip Bits: 标签:位运算 题目:Determine the number of bits required to flip if you want to convert integer n to integer m. 解题思路: 给出两个数字a和b,返回两个数字中需要转换的内容这道题主要是
阅读全文

浙公网安备 33010602011771号