- 博客(40)
- 资源 (12)
- 收藏
- 关注
转载 mysql的查询、子查询及连接查询
一、mysql查询的五种子句 where(条件查询)、having(筛选)、group by(分组)、order by(排序)、limit(限制结果数) 1、where常用运算符: 比较运算符 > , ),>= , in(v1,v2..vn)
2016-05-30 11:00:27 332
转载 SQL多表连接查询(详细实例)
本文主要列举两张和三张表来讲述多表连接查询。新建两张表:表1:student 截图如下:表2:course 截图如下:(此时这样建表只是为了演示连接SQL语句,当然实际开发中我们不会这样建表,实际开发中这两个表会有自己不同的主键。)一、外连接外连接可分为:左连接、右连接、完全外连接。1、左连接 left join 或 left outer joinSQ
2016-05-30 10:39:10 530
原创 183. Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.Table: Customers.+----+-------+| Id | Na
2016-05-28 21:31:34 982
原创 175. Combine Two Tables
Table: Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Per
2016-05-28 20:36:12 494
原创 182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | [email protected] || 2 | [email protected] || 3 | [email protected] |+----+---------+For
2016-05-28 20:08:34 853
原创 181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name | Salary |
2016-05-28 19:30:33 959
原创 105. Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.递归/** * Definition for a binary tree node. * stru
2016-05-27 22:46:49 443
原创 145. Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solut
2016-05-27 20:46:49 274
原创 94. Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solutio
2016-05-27 12:11:47 632
原创 144. Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive solu
2016-05-27 10:00:06 284
原创 数据的操作
##数据的操作###插入插入完整数据记录INSERT INTO table_name (field1,field2...fieldn) VALUES(value1,value2...valuen);field:字段名value:数值INSERT INTO table_name VALUES(value1,value2...valuen);插入部分数据记录INSERT
2016-05-26 16:28:53 429
原创 触发器的操作
##触发器的操作###创建执行一条语句的触发器CREATE TRIGGER trigger_name BEFORE|AFTER trigger_event ON table_name FOR EACH ROW trigger_STMT(有关触发事件的操作)eg:CREATE TRIGGER trigger_diarytime BERORE INSERT ON t_dept FO
2016-05-26 16:27:52 290
原创 视图的操作
##视图的操作##创建视图:(封装复杂的查询语句)CREATE VIEW view_name AS 查询语句; 查看视图的详细信息:SHOW TABLES;(表和视图都显示)SHOW TABLE STATUS FROM database_name;SHOW TABLE STATUS FROM database_name LIKE "table_name"; 查看视图的定义信息
2016-05-26 16:27:06 578
原创 索引的操作
##索引的操作###创建普通索引#创建普通表时创建普通索引:CREATE TABLE table_name( 属性名 数据类型, 属性名 数据类型, ...... 属性名 数据类型, INDEX|KEY 【索引名】(属性名1 【(长度)】 【ASC|DESC】));eg:USE company;CREATE TABLE t_dept( deptno INT, dnam
2016-05-26 16:26:18 351
原创 表的操作
create database db_name;#创建数据库use db_name;#选择数据库create table table_name( 属性名 数据类型, 属性名 数据类型, ....... 属性名 数据类型);查看表查看列(表的字段信息):desc table_name;查看表的所有信息:show create table table_name; ALT
2016-05-26 16:23:04 247
原创 MySQL存储引擎
几个常用存储引擎的特点下面我们重点介绍几种常用的存储引擎并对比各个存储引擎之间的区别和推荐使用方式。特点MyisamBDBMemoryInnoDBArchive存储限制没有没有有64TB没有事务安全 支持 支持 锁机制表锁页锁表锁行锁行锁
2016-05-26 16:22:08 279
原创 数据库基本操作
##数据库操作##创建数据库:create database db_name;查看数据库:show databases;选择数据库:use database db_name;删除数据库:drop database db_name;
2016-05-26 16:19:17 269
原创 6. ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I
2016-05-26 12:08:08 544
原创 102. Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20
2016-05-26 09:55:17 264
原创 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum
2016-05-25 22:04:25 253
原创 110. Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
2016-05-25 21:13:09 296
原创 111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.BFS, C++, 8ms, Beats 99.94% su
2016-05-25 16:53:53 243
原创 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f
2016-05-25 11:44:49 231
原创 100. Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.我的颠簸之路:
2016-05-25 11:08:19 242
原创 257. Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]深度优先搜索D
2016-05-25 09:43:04 294
原创 226. Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by Max Howe
2016-05-23 20:54:31 269
原创 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.1. Depth-first-searchO
2016-05-23 18:04:27 327
原创 258. Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on
2016-05-23 17:38:40 219
原创 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the
2016-05-23 16:47:03 233
原创 345. Reverse Vowels of a String
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 = "leetcode", return "leotcede".笨笨的方
2016-05-23 16:44:47 365
原创 344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".Subscribe to see which companies asked this question临时对象clas
2016-05-23 15:06:00 233
原创 40亿个随机排列整数问题
问题: 给定最多包含40亿个随机排列的32位整数的顺序文件,找出一个不在文件中的32位整数(在文件中至少缺失一个这样的数——为什么?)。在具有足够内存的情况下,如何解决该问题?如果有几个外部的“临时”文件可用,达十年后仅有几百字节的内存,又该如何解决?解答: (1)如果具有足够的内存,可用采用位图法进行解决。需要2^32/8/1024/1024=512MB的内存。如果某个数在在文
2016-05-22 12:20:52 1891
原创 n元一维向量旋转问题
问题描述:B.将一个n元一维向量向左旋转i个位置。例如,当n=8且i=3时,向量abcdefgh旋转为defghabc. 简单的代码使用一个n元的中间向量在n步内完成该工作。你能否仅使用数十个额外字节的存储空间,在正比于n的时间内完成该向量的旋转?问题解析:1、以正比于n的时间(相当于n步内)完成该操作,那么就是每个元素的移动都差不多一步到位,如将第4位的d一步移动到第
2016-05-22 11:08:58 661
原创 比较两个字符串是否为变位词
(1) 问题描述:如果两个字符串的字符一样,但是顺序不一样,被认为是兄弟字符串,问如何在迅速匹配兄弟字符串(如,bad和adb就是兄弟字符串)。 (2) 注意:第一点中讨论了字符串包含问题,但是不要以为两个字符串互相包含就是(变位词)兄弟字符串了,例如aabcde和edcba互相包含,但它们不是变位词。 (3) 解决方案: 思路一 给每个字母分配一个素数,可以通过判断两个字符
2016-05-21 14:43:48 1196
原创 字符串包含问题
(1) 问题描述:存在字符串1和字符串2,假设字符串2相对较短,如何快速地判定字符串2中的字符都存在于字符串1里(假定字符串只包含字母)? (2) 举例:字符串1为ABCDEFGHIJK,字符串2为ABCDE,则字符串1包含字符串2,因为字符串2中包含的字母在字符串1中也都有。 (3) 解决方案: 思路一 最直接的思路就是针对字符串2中的每个字符,轮询字符串1进行比较,看是
2016-05-21 14:41:25 864
原创 变位词问题
问题描述: C. 给定一个英语词典,找出其中的所有变位词集合。例如,“pots”、“stop”和“tops”互为变位词,因为每一个单词都可以通过改变其他单词中的字母的顺序来得到。 问题解析: 1、变位词具有相同的长度,相同的字符,唯一的区别就是这些相同的字符按照不同的顺序排列成不同的字符串而已。如果有一种方法唯一标识这些相同的字符,那么这个问题好解决了。 解决方案: 方
2016-05-21 14:27:49 799
原创 11. Container With Most Water
Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lin
2016-05-14 22:14:31 223
原创 4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).To solve this problem, we nee
2016-05-14 21:25:46 375
原创 磁盘排序算法(多路归并、位图)
问题描述 输入:一个最多包含n个正整数的文件,每个数都小于n,其中n=107。如果在输入文件中有任何正数重复出现就是致命错误。没有其他数据与该正数相关联。 输出:按升序排列的输入正数的列表。 约束:最多有1MB的内存空间可用,有充足的磁盘存储空间可用。运行时间最多几分钟,运行时间为10秒就不需要进一步优化。程序设计与实现概要:应用位图或位向量表示集合。可用一个10位长的字符
2016-05-14 16:26:09 7016
原创 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: Given nums =
2016-05-13 21:45:21 343
STL源码讲解文档
2016-06-05
STL源码剖析 候捷配套
2016-06-05
STL source code
2016-06-05
SX1278模块
2015-11-18
BLE-CC41-A蓝牙模块
2015-11-18
SX1276/1278LoRa模块测试程序
2015-11-18
BLE-CC41-A蓝牙模块驱动程序
2015-11-18
虚拟化知识
2015-08-18
操作系统:精髓与设计原理02(读书笔记)
2015-07-26
操作系统:精髓与设计原理01(读书笔记)
2015-07-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人