最近公司搬家了,有两天没写了,今天闲下来了,继续开始算法之路. leetcode的题目如下: Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: Y…
哈哈,我又来了.昨天发现题目太简单就没有放上来,今天来了一道有序链表的题.题目如下: Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. 题目分析:简单来说就是去除有序链…
题目: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 题目分析: 将罗马数字转换成阿拉伯数字,规则如下:罗马数字共有七个,即I(1),V(5),X(10),L(50),C(100),D(500),M(1000). 按照下面的规则可以表示任意正整数. 重复数次:一个罗马数字重复几次,就表示这个数的几倍.右加左减:在一个较大的罗马数…
题目如下: 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 many times as it shows in both arrays. The result can be in…
题目是这样的 Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, i…
#pragma strict private var m_pCubeObj : GameObject = null; private var m_pMeshFilter : MeshFilter = null; public var m_fTramslateSpeed : float = 20.0f; public var m_fRotateSpeed : float = 60.0f; function OnGUI(){ GUI.Label(new Rect(0.0f,0.0f,Screen.w…
之前对于闭包的理解只是很肤浅的,只是浮于表面,这次深究了一下闭包,下面是我对闭包的理解. 什么是闭包? 引用高程里的话 => 闭包就是有权访问另一个作用域中变量的函数,闭包是由函数以及创建该函数的词法环境组成而成 记住,闭包是一个函数,废话不多说,先来个例子: function makeFunc() { var name = "Mozilla"; function displayName() { alert(name); } return displayName; } var m…
讲这个方法之前,我们应该先了解下插入节点时浏览器会做什么. 在浏览器中,我们一旦把节点添加到document.body(或者其他节点)中,页面就会更新并反映出这个变化,对于少量的更新,一条条循环插入也会运行很好,也是我们常用的方法.代码如下: for(var i=0;i<5;i++) { var op = document.createElement("span"); var oText = document.createTextNode(i)…
#pragma strict public var m_pA : Vector3 = new Vector3(2.0f, 4.0f, 0.0f); public var m_pB : Vector3 = new Vector3(-4.0f, 2.0f,0.0f); private var m_pTemp : Vector3 = new Vector3(0.0f,0.0f,0.0f); private var m_fTemp : float = 0.0f; private var m_fAngle…
#pragma strict function Awake(){ var pMeshFilter : MeshFilter = gameObject.AddComponent(typeof(MeshFilter)) as MeshFilter;//网格过滤器 var pMeshRender : MeshRenderer = gameObject.AddComponent(typeof(MeshRenderer)) as MeshRenderer;//网格渲染 var pMesh : Mesh =…