自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 资源 (2)
  • 收藏
  • 关注

转载 网络间进程的通信--socket

网络中进程之间如何通信?首要解决的问题是如何唯一标识一个进程,否则通信无从谈起!在本地可以通过进程PID来唯一标识一个进程,但是在网络中这是行不通的。其实TCP/IP协议族已经帮我们解决了这个问题,网络层的“ip地址”可以唯一标识网络中的主机,而传输层的“协议+端口”可以唯一标识主机中的应用程序(进程)。这样利用三元组(ip地址,协议,端口)就可以标识网络的进程了,网络中的进程通信就可以利用这

2017-10-10 15:11:45 540

转载 C++ 重写重载重定义区别

C++ 重写重载重定义区别  重载overload:是函数名相同,参数列表不同 重载只是在类的内部存在。但是不能靠返回类型来判断。重写override:也叫做覆盖。子类重新定义父类中有相同名称和参数的虚函数。函数特征相同。但是具体实现不同,主要是在继承关系中出现的 。重写需要注意:1 被重写的函数不能是static的。必须是virtual的

2017-10-09 11:14:12 280

原创 513. Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input:2/ \ 1 3Output: 1Example 2: Input: 1 / \ 2 3 / / \4 5 6 / 7Output: 7Note:

2017-10-08 19:02:52 194

原创 leetcode 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. 递归实现/** * De

2017-10-08 18:59:04 171

原创 leetcode 105 /106 . Construct Binary Tree

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 tr

2017-10-08 18:56:49 187

原创 leetcode 169. Majority Element

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element alway

2017-10-07 22:09:00 132

原创 leetcode 530. Minimum Absolute Difference in BST/404. Sum of Left Leaves/563. Binary Tree Tilt

Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example: Input:1 \ 3 / 2Output: 1Explanation: The min

2017-10-07 12:24:35 162

原创 leetcode 349. Intersection of Two Arrays

Pick One 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. The r

2017-10-07 11:48:00 135

原创 leetcode 492. Construct the Rectangle

Pick One For a web developer, it is very important to know how to design a web page’s size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose

2017-10-05 15:35:41 151

原创 leetcode 538. Convert BST to Greater Tree

Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. Example

2017-10-05 14:31:43 146

原创 leetcode 389. Find the Difference

Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was added

2017-10-04 15:32:45 154

原创 leetcode 448. Find All Numbers Disappeared in an Array

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could

2017-10-04 11:32:02 107

原创 leetcode 258. Add Digits /371. Sum of Two Integers

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 only one di

2017-10-04 11:09:14 170

原创 leetcode 226. Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1镜像翻转 左子树和右子树交换,利用递归完成/** * Definition for a binary tree node. *

2017-10-03 17:57:25 116

原创 leetcode 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.BFS或 DFS/** * Definition for a binary tr

2017-10-03 17:10:38 127

原创 leetcode 637. Average of Levels in Binary Tree

Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 20 / \ 15 7 Output: [3, 14.5, 11] Exp

2017-09-30 21:32:37 148

原创 leetcode 690. Employee Importance

You are given a data structure of employee information, which includes the employee’s unique id, his importance value and his direct subordinates’ id. For example, employee 1 is the leader of employe

2017-09-30 20:10:30 1070

原创 leetcode 682. Baseball Game

You’re now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Integer (one round’s score): Directly represents the number of points you get in

2017-09-30 17:54:22 1236 1

原创 leetcode-496. Next Greater Element I

/*You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2.

2017-09-30 15:48:50 212

原创 分治:合并排序的java程序实现

合并排序:采用分治策略将待排序的元素分成大小大致相同的两个子集合,先对两个子集合进行排序,将排序好的子集合合并成排好序的集合。其算法是复杂度T(n)=O(nlogn)合并排序主要中主要是在merge()这个方法中进行了排序。mergesort()仅仅是对数组进行的划分。import java.util.Arrays;import java.util.Scanner;publi

2015-08-31 15:16:33 667 1

原创 分治:棋盘覆盖的java程序实现

在一个2k x 2k ( 即:2^k x 2^k )个方格组成的棋盘中,恰有一个方格与其他方格不同,称该方格为一特殊方格,且称该棋盘为一特殊棋盘。在棋盘覆盖问题中,要用4种不同形态的L型骨牌覆盖给定的特殊棋盘上除特殊方格以外的所有方格,且任何2个L型骨牌不得重叠覆盖。import java.awt.BorderLayout;import java.awt.Color;import

2015-08-29 15:25:09 684

原创 分治:二分搜索法算法的java实现

二分搜索算法是运用分治策略的典型例子问题描述:给定已排好序的n个元素a[0,n-1],现在要在这个n个元素中找到某一特定的元素x。    一般的按顺序寻找的方法时间复杂度是O(n),如果使用二分法,充分利用元素间的次序关系,采用分治策略。那么最坏情况下用O(logn)的时间就能完成搜索。思想:把n个元素分成个数大致相同的两半,取a[n/2]与x比较。如果x=a[n/2],则找到了,算法

2015-08-25 16:27:36 1002

原创 递归:汉罗塔问题的程序实现

Hanoi:这里解决的是把a塔按规则移到b塔,有中间塔c塔。    这个问题有一个简单的解法,假设a,b,c排成一个三角形,a→b→c→a构成顺时针循环。在移到的过程中,如果是奇数次移动,则将最小的圆盘移到顺时针方向的下一个塔上;如果是偶数次移动,则保持最小的圆盘不动,在其他两个塔之间,将较小的圆盘移到另一个塔上。但是这个方法没法总结其设计思想。递归设计见程序。import java.

2015-08-13 15:04:41 1482

原创 递归:整数划分的java编程实现

整数划分:     正整数n表示成一系列正整数之和:     n=n1+n2+n3...+nk(其中,n1>=n2>=n3...>=nk>=1,k>=1),p(n)就是正整数n的不同划分个数,即正整数的划分数。    那么在正整数n的所有不同划分中,把最大加数不大于m的划分个数记作q(n,m)。那么其递归关系如下:(1)q(n,1)=1,n>=1其中m=1,即最大加数只能为

2015-08-13 10:24:03 3172 1

原创 递归:全排列的java实现

全排列:比如有一组数123,它的全排列有123,132,213,231,321,312。下面的实现也考虑了重复的情况。        虽然实现了全排列,但是没有很好的理解。不知道有没有大神可以讲解一下两个Swap的作用。import java.util.Scanner;public class Permlist { /** * R={r1,r2,r3...rn} n=1时,pe

2015-08-12 17:27:52 459

原创 递归:阶乘以及菲波那切数列的程序实现

分治法:把一个难以直接解决的大问题分割成一些规模较小的相同问题,以便各个击破,分而治之。    分治法中的子问题和原问题的类型一致,子问题不断缩小直至变成可以求解的简单问题,从而就引入了递归算法。         直接或间接调用自身的算法称为递归算法。例子1:阶乘函数import java.util.Scanner;/*阶乘函数 * 递归定义:n!={1 n=0 *

2015-08-08 14:53:43 1225

原创 算法的复杂度计算

算法有四种特性:(1)输入(2)输出(3)确定性(4)有限性:每条指令的执行次数是有限的,执行时间也是有限的算法的复杂性:算法的复杂性分为时间复杂性和空间复杂性。C=F(N,I,A)   C:算法复杂度   N:待解决问题的规模   A:算法的本身算法的复杂性一般有最坏情况、最好情况和平均情况。其中最坏情况下的复杂度的可操作性最好并且最具有实际价值。复杂性渐进性

2015-08-08 13:51:57 958

Andrew Rollings and Ernest Adams on Game Design

Andrew Rollings and Ernest Adams on Game Design. PDF版本

2017-12-21

游戏大师Chris Crawford谈互动叙事

游戏大师 游戏开发,中文版,高清pdf.[包含前三章内容]。

2017-11-29

空空如也

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

TA关注的人

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