自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

我在天上飘的博客

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

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

原创 164. Maximum Gap

Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements

2016-05-27 10:07:52 214

原创 57. Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E

2016-05-27 10:00:47 210

原创 线程的互斥

实现互斥访问的方式:使用临界区对象、使用互斥对象和使用信号量。互斥对应一个CMutex类的对象,只有拥有互斥对象的线程才具有访问共享资源的权限。使用互斥对象时必须首先为共享数据定义一个全局互斥对象。定义后,调用Lock()成员函数获得互斥对象的拥有权,调用UnLock()释放拥有权。示例:#include#includeusing namespace std;int arr

2016-05-27 08:36:39 335

原创 Android平台的JNI开发初步

参考了:http://www.cnblogs.com/yejiurui/p/3476565.htmlhttp://blog.sina.com.cn/s/blog_4298002e01013zk8.htmlJNI是Java Native Interface的缩写,通过JNI可以方便我们在Android平台上进行C/C++编程。要用JNI首先必须安装Android的NDK,

2016-05-26 21:16:53 314

原创 Android平台的JNI开发初步

参考了:http://www.cnblogs.com/yejiurui/p/3476565.htmlhttp://blog.sina.com.cn/s/blog_4298002e01013zk8.htmlJNI是Java Native Interface的缩写,通过JNI可以方便我们在Android平台上进行C/C++编程。要用JNI首先必须安装Android的NDK,

2016-05-26 19:48:30 246

原创 56. Merge Intervals

Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].【思路】首先必须对区间按照左边元素的大小进行排序,然后对排序后的数组进行遍历,合并。能够合并的区间必

2016-05-26 11:19:36 188

转载 179. Largest Number

Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be ve

2016-05-26 10:31:15 242

原创 75. Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers

2016-05-26 09:43:41 246

转载 324. Wiggle Sort II

Given an unsorted array nums, reorder it such that nums[0] nums[2] .Example:(1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6]. (2) Given nums = [1, 3, 2, 2, 3, 1], one po

2016-05-26 09:15:02 205

原创 找出字符串

有一个排过序的字符串数组,但是其中有插入了一些空字符串,请设计一个算法,找出给定字符串的位置。算法的查找部分的复杂度应该为log级别。给定一个string数组str,同时给定数组大小n和需要查找的string x,请返回该串的位置(位置从零开始)。测试样例:["a","b","","c","","d"],6,"c"返回:3【思路】二分查找,需要特殊处理的是当st

2016-05-25 13:17:43 222

原创 元素查找

题目描述有一个排过序的数组,包含n个整数,但是这个数组向左进行了一定长度的移位,例如,原数组为[1,2,3,4,5,6],向左移位5个位置即变成了[6,1,2,3,4,5],现在对于移位后的数组,需要查找某个元素的位置。请设计一个复杂度为log级别的算法完成这个任务。给定一个int数组A,为移位后的数组,同时给定数组大小n和需要查找的元素的值x,请返回x的位置(位置从零开始)。

2016-05-25 11:31:00 213

原创 8. String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2016-05-25 10:10:42 175

原创 树转链表

题目描述有一个类似结点的数据结构TreeNode,包含了val属性和指向其它结点的指针。其可以用来表示二叉查找树(其中left指针表示左儿子,right指针表示右儿子)。请编写一个方法,将二叉查找树转换为一个链表,其中二叉查找树的数据结构用TreeNode实现,链表的数据结构用ListNode实现。给定二叉查找树的根结点指针root,请返回转换成的链表的头指针。'

2016-05-24 21:45:59 607

原创 检查是否为BST

题目描述请实现一个函数,检查一棵二叉树是否为二叉查找树。给定树的根结点指针TreeNode* root,请返回一个bool,代表该树是否为二叉查找树。/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int

2016-05-24 20:14:02 295

转载 简单的Socket示例

【服务器端步骤】初始化Windows Socket库创建Socket: socke函数绑定Socket: bind函数监听Socket: listen接受Socket:accept接收、发送数据, send/Recv关闭连接 closesocket【客户端步骤】初始化Windows Socket库创建Socket连接Socket :connect函数

2016-05-24 15:04:24 1301 1

原创 有向路径检查

题目描述对于一个有向图,请实现一个算法,找出两点之间是否存在一条路径。给定图中的两个结点的指针UndirectedGraphNode* a,UndirectedGraphNode*b(请不要在意数据类型,图是有向图),请返回一个bool,代表两点之间是否存在一条路径(a到b或b到a)。/*struct UndirectedGraphNode { i

2016-05-23 22:21:29 334

原创 二叉树平衡检查

题目描述实现一个函数,检查二叉树是否平衡,平衡的定义如下,对于树中的任意一个结点,其两颗子树的高度差不超过1。给定指向树根结点的指针TreeNode* root,请返回一个bool,代表这棵树是否平衡。【思路】递归/*struct TreeNode { int val; struct TreeNode *left; struct Tre

2016-05-23 21:35:21 198

原创 找出字符串

题目描述有一个排过序的字符串数组,但是其中有插入了一些空字符串,请设计一个算法,找出给定字符串的位置。算法的查找部分的复杂度应该为log级别。给定一个string数组str,同时给定数组大小n和需要查找的stringx,请返回该串的位置(位置从零开始)。测试样例:["a","b","","c","","d"],6,"c"返回:3【思路】题目要求log级别

2016-05-23 16:47:16 253

原创 变位词排序

题目描述请编写一个方法,对一个字符串数组进行排序,将所有变位词合并,保留其字典序最小的一个串。这里的变位词指变换其字母顺序所构成的新的词或短语。例如"triangle"和"integral"就是变位词。给定一个string的数组str和数组大小int n,请返回排序合并后的数组。保证字符串串长小于等于20,数组大小小于等于300。测试样例:["ab","ba","abc

2016-05-23 16:40:49 598

原创 输出单层结点

对于一棵二叉树,请设计一个算法,创建含有某一深度上所有结点的链表。给定二叉树的根结点指针TreeNode* root,以及链表上结点的深度,请返回一个链表ListNode,代表该深度上所有结点的值,请按树上从左往右的顺序链接,保证深度不超过树的高度,树上结点的值为非负整数且不超过100000。【思路】用两个队列实现树的层序遍历,当遍历到dep层时,创建链表。

2016-05-23 15:53:31 207

原创 196. Delete Duplicate Emails

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.+----+------------------+| Id | Email |+----+-----

2016-05-23 11:12:39 269

原创 175. Combine Two Tables

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

2016-05-23 11:06:36 204

原创 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 11503

转载 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

贝叶斯分类方法

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

2015-11-03

空空如也

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

TA关注的人

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