Yvan Jiang的专栏

CS、CV、ML

Leetcode Linked List Cycle

Given a linked list, determine if it has a cycle in it. 使用两个指针,一前一后,(p,q),p与q相差一个位置,之后p移动一步,q相对应移动两步,如果存在环,那么q和p一定会相遇 /** * Definition for singly-...

2015-05-29 22:07:52

阅读数 260

评论数 0

Leetcode Implement strStr()

Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. class Solution { ...

2015-05-29 09:54:32

阅读数 194

评论数 0

C++ string类型和char类型转换

在C++常用的字符串对象类string,有很多实用的类成员函数,比如求字符串的长度,查找字符串的子串,字符串连接等 等我们使用C语言的一些处理字符串的函数的时候,由于我们使用的是string类对象,所以需要转化一下,由string-->char类型转换 这时候需要时候c_str()函数,作用...

2015-05-29 09:48:24

阅读数 275

评论数 0

torch7 install 环境搭建

1、before intallation,you should install node.js,gfx.js Node.js是一个软件平台,通常用于构建大规模的服务器端应用。Node.js使用JavaScript作为其脚本语言,由于其非阻塞I/O设计以及单线程事件循环机制,使得它可以交付超高...

2015-05-27 09:00:39

阅读数 5717

评论数 1

Leetcode 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 farthe...

2015-05-26 09:54:35

阅读数 285

评论数 0

Leetcode Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], ...

2015-05-25 09:49:35

阅读数 239

评论数 0

从Linux系统拷贝的文本文件到windows下出现乱码

从Linux系统拷贝的文本文件到windows下,用记事本打开的时候出现乱码,但是发现用写字板打开的时候显示正常,很奇怪? 之后用写字板打开文件-》另存为,保存类型选择Unicode文本文档,发现再次用记事本打开的时候一切显示正常了。 出现这种情况的原因为两种操作系统的中文压缩方式不同,在wind...

2015-05-23 19:36:23

阅读数 1615

评论数 0

Leetcode Kth Largest Element in an Array

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For ...

2015-05-23 16:43:25

阅读数 212

评论数 0

Leetcode Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings. 题意是写一个函数,找到字符串最大相同的前缀。 首先以第一个字符串的子串作为参考,依次和其它字符串子串比较,如果相同,则继...

2015-05-23 16:30:17

阅读数 190

评论数 0

Leetcode Pow(x, n)

Implement pow(x, n). 题目是很简单,就是求x的n次方,但是提交的时候很费劲,TLE,超时,主要考虑一些条件问题: 1、result 2、x = 1 或者-1的时候,返回值根据n的奇偶情况返回1或者-1 3、n = 0的情况,返回值1. 4、n 不能直接累积,肯定会...

2015-05-23 09:35:46

阅读数 175

评论数 0

Leetcode Rotate Array

Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4...

2015-05-22 21:53:44

阅读数 201

评论数 0

Leetcode Reverse Bits

Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), r...

2015-05-22 20:46:24

阅读数 246

评论数 0

Leetcode Number of 1 Bits

Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 3...

2015-05-22 20:21:50

阅读数 204

评论数 0

Leetcode Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the las...

2015-05-22 10:46:02

阅读数 227

评论数 0

Leetcode 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers...

2015-05-18 19:49:29

阅读数 229

评论数 0

Leetcode 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() -- Re...

2015-05-18 19:47:26

阅读数 202

评论数 0

Leetcode Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single...

2015-05-18 19:45:05

阅读数 181

评论数 0

Leetcode Add Binary

Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". ...

2015-05-18 19:41:58

阅读数 199

评论数 0

Leetcode 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 identic...

2015-05-18 19:40:00

阅读数 203

评论数 0

Leetcode 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 th...

2015-05-18 19:36:38

阅读数 151

评论数 0

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