自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

我在天上飘的博客

自信的生活态度+学海无涯乐作舟

  • 博客(209)
  • 资源 (1)
  • 收藏
  • 关注

原创 175. Combine Two Tables

Table: Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Per

2016-05-23 11:06:36 203

原创 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-23 10:59:01 224

原创 197. Rising Temperature

Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.+---------+------------+------------------+| Id(INT) | Date(DA

2016-05-23 10:11:14 272

原创 176. Second Highest Salary

Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For exa

2016-05-23 10:02:35 252

原创 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-23 09:51:51 219

原创 48. Rotate Image

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?【思路】顺时针转90度,可先将按对角线互换,再按垂直中心线互换。class Solution {

2016-05-23 08:47:13 235

转载 mysql查询练习

Sutdent表的定义字段名字段描述数据类型主键外键非空唯一自增Id学号INT(10)是否是是是Name姓名VARCHAR(20)否

2016-05-22 09:58:52 11497

转载 34. Search for a Range

Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found

2016-05-21 19:59:22 233

原创 350. Intersection of Two Arrays II

Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should appear as ma

2016-05-21 16:19:25 1297 1

原创 274. H-Index

Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A

2016-05-19 15:09:00 288

原创 49. Group Anagrams

Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note:

2016-05-19 10:52:48 225

原创 349. Intersection of Two Arrays[][

Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.T

2016-05-19 10:26:41 618

原创 300. Longest Increasing Subsequence最长递增子序列

Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101], ther

2016-05-18 20:11:23 198

原创 64. Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at

2016-05-18 18:27:12 174

转载 115. Distinct Subsequences

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 formed from the original string by deleting some (can be non

2016-05-18 17:25:50 196

原创 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-18 10:48:08 185

原创 141. Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?【思路】新建了一个map,访问过的节点置为true,当再次访问此节点时表示有环存在。/** * Definition for singly-linked li

2016-05-17 16:20:53 176

原创 237. Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value

2016-05-17 11:04:05 175

翻译 82. Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->

2016-05-16 16:22:58 263

原创 303. Range Sum Query - Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan

2016-05-12 20:17:39 175

原创 222. Count Complete Tree Nodes

Given a complete binary tree, count the number of nodes.计算完全二叉树的节点数目。满二叉树的节点数是2^h-1, h为树的高度。/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left;

2016-05-11 15:58:06 164

原创 129. Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the tota

2016-05-11 15:23:23 214

原创 103. Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary

2016-05-11 11:32:39 194

翻译 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]./** * Definition for

2016-05-11 10:53:34 903

原创 341. Flatten Nested List Iterator

Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Given the li

2016-05-11 09:07:03 334

原创 173. Binary Search Tree Iterator

/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class BSTIte

2016-05-10 22:19:57 184

原创 150. Evaluate Reverse Polish Notation

Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1",

2016-05-10 17:25:48 164

原创 155. Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get

2016-05-10 16:43:18 166

原创 28. Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.【思路】KMP字符串匹配问题,难点在于获得next(j)的值。class Solution {public: void

2016-05-10 15:23:34 165

原创 回溯法实现格雷码

For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:00 - 001 - 111 - 310 - 2回溯法可实现,但是不符合LeetCode的答案顺序。【思路】每一位要么是1,要么是0。class Solution {public://正确的,但不符合输出顺序。 void bits(in

2016-05-09 22:27:12 706

转载 46. Permutations

Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].【思

2016-05-09 19:12:52 181

原创 208. Implement Trie (Prefix Tree)字典树

Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.在Trie树中主要有3个操作,插入、查找和删除。一般情况下Trie树中很少存在删除单独某个结点的情况,因此只

2016-05-09 14:46:20 500

原创 【C++】类的静态数据成员

静态数据成员需要单独初始化,而且是在类的外面。静态成员函数不能调用非静态数据成员和非静态成员函数。静态数据成员只有一份,且不依赖对象数量而存在。静态成员函数不能用const修饰符。普通成员函数可以调用静态成员函数。静态成员函数可以独立访问。 类名::静态成员函数名非静态成员必须通过类的对象访问。

2016-05-06 10:54:39 411

原创 设置光标位置

typedef struct _COORD { // coord.SHORT X; // horizontal coordinateSHORT Y; // vertical coordinate} COORD;WINDOWS API中定义的一个结构,表示一个字符在控制台屏幕上的坐标,左上角为(0,0)。使用示例: int main(){ HANDLE h

2016-05-05 15:33:48 1769

原创 C++代理类

代理模式:对象A不是直接访问对象C,而是通过一个中间对象B间接访问对象C。对象B则可以利用这一有利位置为A提供一个与C完全不同的接口,或做一些C本来不做的事!流程如下图所示:A -----> B ------> C这样B就是C的代理类,C可被称作实现类,A是客户代码。代理类就是指某个基类以及其子类的代理,其功能是使之能在容器中也表现出多态性.而没有动态内存管理的烦恼.缺点:即每

2016-05-05 11:07:13 276

原创 143. Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it t

2016-05-04 17:17:56 169

原创 147. Insertion Sort List

Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */

2016-05-04 15:58:20 151

原创 148. Sort List

Sort a linked list in O(n log n) time using constant space complexity.【思路】归并排序的时间复杂度O(nlogn)/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next;

2016-05-04 15:02:18 148

原创 86. Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of

2016-05-04 11:14:40 149

翻译 37. Sudoku Solver

Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku

2016-05-04 10:17:59 177

贝叶斯分类方法

将Iris数据集进行分类,利用最大后验估计的贝叶斯方法。Matlab代码。

2015-11-03

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除