
=====leeetcode=====
林伏案
妖蛾子良多的范老爷
展开
-
201604-4(游戏)
/*ccf 201604_4 普通的bfs,但是注意当无路可走的时候是可以回到上一次走过的格子的,所以不能用普通的 标记像vis[i][j]来表示某个格子曾走过。应该采用拆点的思想,vis[i][j][t]表示t时刻走过 格子i,j。其余按照套路走即可。*/#include #include #include #include using names原创 2017-03-07 17:30:06 · 344 阅读 · 0 评论 -
leetcode--3. Longest Substring Without Repeating Characters
尺取法首先设置头尾两个指针,都指向头,然后尾指针开始遍历,在遍历过程中记录每个字母出现个数,每次遍历若当前字母没有出现过,则更新答案长度。若出现过,则将头指针移到重复字母的后面一位。然后继续重复上述操作。最后返回答案即可。class Solution {public: int lengthOfLongestSubstring(string s) { if(s.le原创 2017-06-19 20:41:49 · 377 阅读 · 0 评论 -
leetcode--4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 = [1,原创 2017-06-20 20:40:13 · 349 阅读 · 0 评论 -
leetcode--7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your function原创 2017-06-21 15:49:33 · 482 阅读 · 0 评论 -
leetcode--1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sam原创 2017-06-21 16:46:49 · 409 阅读 · 0 评论