leetcode 226 Invert Binary Tree递归方法/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * stru...
分类:
其他好文 时间:
2015-10-17 17:44:24
阅读次数:
135
单例模式是设计模式中最简单,他要求设计者保证该类只有一个实例,之前我是挂载脚本实现单例,该方法非常简单,使用的直接调用Singleton.instance就可以了using UnityEngine;using System.Collections;public class Singleton : M...
分类:
其他好文 时间:
2015-10-17 17:43:13
阅读次数:
164
package demo;public class Tongji { private static int n; public Tongji() { n++;//次new一个对象的时候都可以给n加1 } public static int getNum() { return n;//返回n值 } @...
分类:
其他好文 时间:
2015-10-17 17:42:23
阅读次数:
99
LeetCode 283 Move Zeroesvoid moveZeroes(int* nums, int numsSize) { int i=0,j=0; for(i;ij) j=i; }}
分类:
其他好文 时间:
2015-10-17 17:41:26
阅读次数:
232
//无论开多大的数都可以,用的很爽;string sum(string s1,string s2){ if(s1.length()=0;i--,j--) { s1[i]=char(s1[i]+(j>=0?s2[j]-'0':0)); if(s1[i]-'0'>...
分类:
其他好文 时间:
2015-10-17 17:40:26
阅读次数:
179
题意:求一个凸多边形中一点到边的最大距离。思路:转换成在多边形内部,到每边距离为d的直线所围成的内多边形是否存在。也就是,二分距离+半平面交。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #in...
分类:
其他好文 时间:
2015-10-17 17:40:20
阅读次数:
153
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.Fo...
分类:
其他好文 时间:
2015-10-17 17:39:44
阅读次数:
128
1 class Solution { 2 public: 3 ListNode* reverseKGroup(ListNode* head, int k) { 4 if(head==NULL||knext;16 17 ...
分类:
其他好文 时间:
2015-10-17 17:39:54
阅读次数:
141
以前一直认为程序中的类有使用到封装继承多态就是面向对象设计,其实不然封装,继承,多态只是面向对象的三大特性,但是在设计程序的时候并不是说类的结构使用到了(或是体现出了)这三个特性就是面向对象,其实真正的面向对象设计是要符合下面的五大原则,面向对象的五大基本原则单一职责原则(SRP)开放封闭原则(OC...
分类:
其他好文 时间:
2015-10-17 17:40:23
阅读次数:
156
MainActivity.classpublic class MainActivity extends AppCompatActivity implements View.OnClickListener{ private Button bt1; private Button bt2; ...
分类:
其他好文 时间:
2015-10-17 17:38:29
阅读次数:
218
Given an array of integers, find out whether there are two distinct indicesiandjin the array such that the difference betweennums[i]andnums[j]is at mo...
分类:
其他好文 时间:
2015-10-17 17:39:40
阅读次数:
167
SynchronizationContext context; 最近写代码用到了这个,特别记录一下。作用如下: // 摘要: // 提供在各种同步模型中传播同步上下文的基本功能。 public class SynchronizationContext { ......
分类:
其他好文 时间:
2015-10-17 17:36:58
阅读次数:
163
一:线段树基本概念1:概述线段树,类似区间树,是一个完全二叉树,它在各个节点保存一条线段(数组中的一段子数组),主要用于高效解决连续区间的动态查询问题,由于二叉结构的特性,它基本能保持每个操作的复杂度为O(lgN)!性质:父亲的区间是[a,b],(c=(a+b)/2)左儿子的区间是[a,c],右儿子...
分类:
其他好文 时间:
2015-10-17 17:36:37
阅读次数:
255
《大道至简》第三章中讲的是团队,team。那么什么是一个团队呢?《汉书》中说“言三人为众”,是指三个人就能成为众,算是一个团队了。团队是由基层和管理层人员组成的一个共同体,它合理利用每一个成员的知识和技能协同工作,解决问题,达到共同的目标。团队为什么至少要以三个人为规模呢?首先,一个人算不得团队,只...
分类:
其他好文 时间:
2015-10-17 17:38:29
阅读次数:
146
使用类的静态字段和构造函数,我们可以跟踪某个类所创建对象的个数。请写一个类,在任何时候都可以向它查询“你已经创建了多少个对象?”。publicclassStudent{publicstaticvoidmain(String[]args){Informationa=newInformation();a...
分类:
其他好文 时间:
2015-10-17 17:36:40
阅读次数:
170
转载请声明出处 http://www.cnblogs.com/datougui/p/4887655.htmlvar target = document;//声明一个变量target专门用来存放鼠标所在的dom元素document.onkeydown = function(event){ var...
分类:
其他好文 时间:
2015-10-17 17:37:57
阅读次数:
133
题目:最长单词给一个词典,找出其中所有最长的单词。样例在词典{ "dog", "google", "facebook", "internationalization", "blabla"}中, 最长的单词集合为["internationalization"]在词典{ "like", "...
分类:
其他好文 时间:
2015-10-17 17:36:08
阅读次数:
209