July 16, 2015

Problem statement:

Longest Substring Without Repeating Characters

Read the blog:

这算法写了很多次, 时间太长, 半年前, 有一次写了二个小时, 写不下去, 想法不好, 没有办法收场; 接着, 又写了四天,

每天二小时, 把上次代码拿出来看, 有什么问题, 改写.  过后想, 这样学习, 时间是浪费的, 打的是疲劳战; 工作中没有

这么复杂的问题, 解决问题, 一定要评估复杂程度.

改变学习方式, 看以上的网页, 看Java的代码, 改写C#; 然后, 增加一些测试的内容, 帮助自己记忆算法的主要思想,

然后, 再改写; 用最简化的测试案例手工检测代码. 二三个小时搞定, 比半年前写的C#简单很多.

关键是用别人的想法, 又加快改写代码的速度, 改写后的代码更方便自己记忆. 这算法用移动窗口, 所以, 在代码中定义

窗口起点, 长度, 什么时候决定更新窗口起点; 用一个数组(256字符)记录每个字符上次所在的位置, 然后, 对当前点,

窗口最右点, 判断是在窗口中出现没有; 间接判断, 看上次的位置在滑动窗口外还是里面.

学习别人的代码, 又练习自己改写代码, 写测试的内容, 多练习总是有新的体会.

Julia发现改写代码, 从其他语言到C#, 让她有机会快速练习写代码, 学习C#语言; 同时, 体会和其他语言的不同, 开阔眼界;

读的再多, 想法很好, 不会写代码实现, 或超过时间范围, 或写起来头痛, 太多错误, 都通过Leetcode训练, 有所提高.

Share C# code:

可以在十几分钟内实现, 体验快速实现的喜悦. 代码不容易出错.

https://github.com/jianminchen/Leetcode_C-/blob/master/3LongestSubstringWithoutRepeating.cs

非常小心, 代码细节太多, 容易出错.

First blog about the same problem:

http://juliachencoding.blogspot.ca/2015/06/longest-substring-without-repeating.html

"撑死胆大的,饿死胆小的. ", 虽然是个歇后语, 但是, 这道题目, 如果只考虑抽象思维, Hashset, 不具体讨论256字符等具体内容,

确实可以10 - 15分钟写出代码. 这是Julia练习的代码, 在第一次训练几个月之后. 
https://github.com/jianminchen/Leetcode_C-/blob/master/3LongestSubstringWithoutRepeating.cs

leetcode: longest substring without repeating characters的更多相关文章

  1. [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  2. [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串

    Given a string, find the length of the longest substring without repeating characters. Example 1: In ...

  3. C++ leetcode Longest Substring Without Repeating Characters

    要开学了,不开森.键盘声音有点大,担心会吵到舍友.今年要当个可爱的技术宅呀~ 题目:Given a string, find the length of the longest substring w ...

  4. [LeetCode]Longest Substring Without Repeating Characters题解

    Longest Substring Without Repeating Characters: Given a string, find the length of the longest subst ...

  5. [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串 C++实现java实现

    最长无重复字符的子串 Given a string, find the length of the longest substring without repeating characters. Ex ...

  6. LeetCode:Longest Substring Without Repeating Characters(最长不重复子串)

    题目链接 Given a string, find the length of the longest substring without repeating characters. For exam ...

  7. LeetCode——Longest Substring Without Repeating Characters

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  8. [Leetcode] Longest Substring Without Repeating Characters (C++)

    题目: Given a string, find the length of the longest substring without repeating characters. For examp ...

  9. [LeetCode] Longest Substring Without Repeating Characters (LinkedHashSet的妙用)

    Given a string, find the length of the longest substring without repeating characters. For example, ...

随机推荐

  1. 【WP8】WebBrowser相关

    2014年09月02日更新 今天用了一下WebBrowser,在使用过程中也遇到了一些问题,在这里做一下记录 虽然WebBrowser比较重,会比较影响性能(除非一定要用到它,否则尽量少用),但有时候 ...

  2. eclipse自动补全的设置(自动提示)

      如果你用过Visual Studio的自动补全功能后,再来用eclipse的自动补全功能,相信大家会有些许失望. 但是eclipse其实是非常强大的,eclipse的自动补全没有VS那么好是因为e ...

  3. android Can't bind to local 86XX for debugger

    For some reason eclipse DDMS always gives the error 'Can't bind to local 86XX for debugger' every ti ...

  4. JavaScript利用装饰模拟实现私有状态

    在经典的面向对象编程中,经常需要将对象的某个状态封装或隐藏在对象内,只有通过对象的一幅幅和能访问这些状态,对外只暴露一些重要的状态变量可以直接读写. 我们可以通过将变量(或参数)装饰在一个构造函数内来 ...

  5. Lind.DDD.Manage项目核心技术分享

    回到目录 关于Lind.DDD.Manager的培训与学习 讲解:张占岭 花名:仓储大叔 主要框架:Lind.DDD,Lind.DDD.Manager 关于Lind.DDD.Manager 由于数据模 ...

  6. CSS3与页面布局学习笔记(五)——Web Font与CSS Sprites(又称CSS精灵、雪碧图)技术

    一.web font web font是应用在web中的一种字体技术,在CSS中使用font-face定义新的字体.先了解操作系统中的字体: a).安装好操作系统后,会默认安装一些字体,这些字体文件描 ...

  7. jQuery静态方法noop,camelCase,nodeName,trim使用和源码分析

    noop方法 jQuery.noop()函数是一个空函数,它什么也不做. 当某些时候你需要传入函数参数,而且希望它什么也不做的时候,你可以使用该函数,也无需再新建一个空的函数. 示例: // 传入一个 ...

  8. 今天再给大家带点html5前端开发的干货模板“text/tpl”怎么用 script template怎么用

    text/tpl 顾名思义就是模板,其实和C++模板函数类似的作用,就是利用他生成一个HMTL内容,然后append或者替换html里面 有什么好处,假如后端返回来的数据都是一样的,但是需要生成不同的 ...

  9. xp操作系统下配置iis,出现了server application error的解决办法

    在网上搜索了很多解决办法,最后发现一个差不多的: Server Application Error The server has encountered an error while loading ...

  10. Linux安全基础:配置network

    在 Linux 系统中,TCP/IP 网络是通过若干个文本文件进行配置的,需要编辑这些文件来完成联网工作.系统中重要的有关网络配置文件有以下几项: /etc/sysconfig/network/etc ...