08 2017 档案

摘要:题目描述 给定一个有n个正整数的数组A和一个整数sum,求选择数组A中部分数字和为sum的方案数。当两种选取方案有一个数字的下标不一样,我们就认为是不同的组成方案。 输入描述: 输入为两行: 第一行为两个正整数n(1 ≤ n ≤ 1000),sum(1 ≤ sum ≤ 1000) 第二行为n个正整数 阅读全文
posted @ 2017-08-31 18:31 immjc 阅读(262) 评论(0) 推荐(0)
摘要:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio 阅读全文
posted @ 2017-08-30 17:47 immjc 阅读(89) 评论(0) 推荐(0)
摘要:Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element. We define an array is non-decr 阅读全文
posted @ 2017-08-30 12:19 immjc 阅读(217) 评论(0) 推荐(0)
摘要:Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: 输出一个树的路径。使用递归的方法 阅读全文
posted @ 2017-08-29 15:58 immjc 阅读(138) 评论(0) 推荐(0)
摘要:Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hello", return "holle". Example 2:Given s 阅读全文
posted @ 2017-08-29 15:11 immjc 阅读(139) 评论(0) 推荐(0)
摘要:Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 阅读全文
posted @ 2017-08-28 14:19 immjc 阅读(122) 评论(0) 推荐(0)
摘要:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leadin 阅读全文
posted @ 2017-08-26 21:45 immjc 阅读(120) 评论(0) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2017-08-26 17:16 immjc 阅读(168) 评论(0) 推荐(0)
摘要:给出两个字符串,找到最长公共子序列(LCS),返回LCS的长度。 给出两个字符串,找到最长公共子序列(LCS),返回LCS的长度。 给出两个字符串,找到最长公共子序列(LCS),返回LCS的长度。 说明 最长公共子序列的定义: 最长公共子序列问题是在一组序列(通常2个)中找到最长公共子序列(注意:不 阅读全文
posted @ 2017-08-26 13:48 immjc 阅读(179) 评论(0) 推荐(0)
摘要:给出一个都是正整数的数组 nums,其中没有重复的数。从中找出所有的和为 target 的组合个数。 注意事项 一个数可以在组合中出现多次。数的顺序不同则会被认为是不同的组合。 您在真实的面试中是否遇到过这个题? Yes 给出一个都是正整数的数组 nums,其中没有重复的数。从中找出所有的和为 ta 阅读全文
posted @ 2017-08-25 21:21 immjc 阅读(153) 评论(0) 推荐(0)
摘要:给出n个物品的体积A[i]和其价值V[i],将他们装入一个大小为m的背包,最多能装入的总价值有多大? 注意事项 A[i], V[i], n, m均为整数。你不能将物品进行切分。你所挑选的物品总体积需要小于等于给定的m。 您在真实的面试中是否遇到过这个题? Yes 给出n个物品的体积A[i]和其价值V 阅读全文
posted @ 2017-08-25 20:27 immjc 阅读(146) 评论(0) 推荐(0)
摘要:在n个物品中挑选若干物品装入背包,最多能装多满?假设背包的大小为m,每个物品的大小为A[i] 注意事项 你不可以将物品进行切割。 在n个物品中挑选若干物品装入背包,最多能装多满?假设背包的大小为m,每个物品的大小为A[i] 注意事项 你不可以将物品进行切割。 在n个物品中挑选若干物品装入背包,最多能 阅读全文
posted @ 2017-08-25 16:40 immjc 阅读(151) 评论(0) 推荐(0)
摘要:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee 阅读全文
posted @ 2017-08-25 13:26 immjc 阅读(133) 评论(0) 推荐(0)
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2017-08-23 17:13 immjc 阅读(126) 评论(0) 推荐(0)
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia 阅读全文
posted @ 2017-08-23 14:59 immjc 阅读(165) 评论(0) 推荐(0)
摘要:Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2017-08-23 14:18 immjc 阅读(138) 评论(0) 推荐(0)
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 此题为两个链表的 阅读全文
posted @ 2017-08-22 22:28 immjc 阅读(100) 评论(0) 推荐(0)
摘要:Write a SQL query to find all duplicate emails in a table named Person. For example, your query should return the following for the above table: Note: 阅读全文
posted @ 2017-08-22 21:05 immjc 阅读(113) 评论(0) 推荐(0)
摘要:正则表达式的作用就是匹配文本,讲一个模式(正则表达式)与一个文本串进行比较。 基本字符匹配 SELECT 列名 FROM 表名 WHERE 列名 REGEXP 条件 ORDER BY 列名; 形式与LIKE相同,只不过REGEXP后面跟的条件为正则表达式。 差别: LIKE匹配整个列。如果被匹配的文 阅读全文
posted @ 2017-08-11 20:10 immjc 阅读(583) 评论(0) 推荐(0)
摘要:主要使用LIKE操作符进行通配搜索,以便对数据进行复杂过滤。 使用通配符创建比较特定数据的搜索模式。 百分号(%)通配符 % 表示任何字符出现任意次数。 SELECT 列名1, 列名2 FROM 表名 WHERE 列名1 LIKE 条件(含一个或多个%); % 可以匹配0个、1个或多个字符。 下划线 阅读全文
posted @ 2017-08-11 19:06 immjc 阅读(596) 评论(0) 推荐(0)
摘要:牛牛拿到了一个藏宝图,顺着藏宝图的指示,牛牛发现了一个藏宝盒,藏宝盒上有一个机关,机关每次会显示两个字符串 s 和 t,根据古老的传说,牛牛需要每次都回答 t 是否是 s 的子序列。注意,子序列不要求在原字符串中是连续的,例如串 abc,它的子序列就有 {空串, a, b, c, ab, ac, b 阅读全文
posted @ 2017-08-11 18:44 immjc 阅读(195) 评论(0) 推荐(0)
摘要:组合WHERE子句来实现功能更强的数据过滤 AND操作符 SELECT 列名1, 列名2, 列名3 FROM 表名 WHERE 条件1 AND 条件2; AND在WHERE子句中指示检索满足所有给定的条件的行 OR操作符 SELECT 列名1, 列名2, 列名3 FROM 表名 WHERE 条件1 阅读全文
posted @ 2017-08-01 19:32 immjc 阅读(185) 评论(0) 推荐(0)
摘要:Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exa 阅读全文
posted @ 2017-08-01 19:07 immjc 阅读(114) 评论(0) 推荐(0)
摘要:There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison 阅读全文
posted @ 2017-08-01 18:47 immjc 阅读(139) 评论(0) 推荐(0)
摘要:使用SELECT语句的WHERE子句指定搜索条件 在SELECT语句中,数据根据WHERE子句中指定的搜索条件进行过滤,WHERE子句在表名之后给出 SELECT 列名1, 列名2 FROM 表名 WHERE 条件; 条件为列中数据的特定值 WHERE子句位置 SELECT + FROM + WHE 阅读全文
posted @ 2017-08-01 13:10 immjc 阅读(224) 评论(0) 推荐(0)