摘要: Write a method to replace all spaces in a string with'%20'. You may assume thatthe string has sufficient space at the end of the string to hold the dd... 阅读全文
posted @ 2015-09-16 21:07 whu.yt 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 初步思路:如果两个字符串长度不等,直接返回 false如果是 ascii 码,新建一个字母表大小的 int数组, 遍历一次字符串将相应数组元素值+1,然后在遍历另一个字符串,将相应数组元素值-1, 如果值已经为0,返回 false。时间复杂度: O(n)空间复杂度: O(1)public class... 阅读全文
posted @ 2015-09-16 19:57 whu.yt 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 最初思路:先遍历一遍获得长度len, 第二次遍历只要遍历一半长度,将索引 k 位置元素与 len-1-k 位置元素互换void reverse(char* str) { int len = 0, i, k; // first traversal get length for (i... 阅读全文
posted @ 2015-09-16 19:30 whu.yt 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 思路: 假设给定字符串用的是ASCII编码,那么总共就只有256个字符,新建一个256个元素的boolean数组, 遍历字符串,将出现的字符在boolean数组所在位置置 1。如果碰到已经置一,表明出现重复字符,返回false。public class IsUniqueChars_1 { ... 阅读全文
posted @ 2015-09-16 15:33 whu.yt 阅读(185) 评论(0) 推荐(0) 编辑
摘要: C vs Java1. 类型, 运算符与表达式1.1 基本数据类型char, int, float, double, short int, long int (可以省略int)signed 和 unsigned 可以限定 char 类型或任何整形类型转换1.2 常量整型常量: 默认为 int, L... 阅读全文
posted @ 2015-09-08 12:05 whu.yt 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 一个设计良好(注意是设计良好的)的hash table 如下操作均为O(1)SearchInsertDelete而self-balancing BST 这些操作均为O(logn)所以在上面这些操作上hash table更优质, 但是如果有如下的需求场景, BST比hash table跟合适得到所有的... 阅读全文
posted @ 2015-08-16 15:15 whu.yt 阅读(247) 评论(0) 推荐(0) 编辑
摘要: Method 1: 先遍历一次获得中长度, 在遍历len-n+1次获得所求nodeMethod 2: 运用双指针, 开始两个指针都指向head, 然后先移动第一个指针, 使其指向第n个node, 然后两个指针一个移动, 当第一个指针移动到尾部时, 第二个node就指向所求nodecode2015-0... 阅读全文
posted @ 2015-08-16 13:44 whu.yt 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Simple solution: 遍历列表, 找到那个node前面的node并改变其nextFast solution: 复制那个node后面node的内容, 然后删除后面的那个nodeps: 这个方法不能用于tail那个node(如果SList的tail是个dummy node则可以)c代码201... 阅读全文
posted @ 2015-08-16 13:37 whu.yt 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 1. Java Basic Structurepublic class Hello { public static void main(String[] args) { System.out.println("Hello World"); } ... 阅读全文
posted @ 2015-07-22 12:27 whu.yt 阅读(243) 评论(0) 推荐(0) 编辑
摘要: I/OSystem.out is a PrintStream object that outputs to the screen.System.in is a InputStream object that reads from the keyboard.InputStream objects (l... 阅读全文
posted @ 2015-07-22 10:32 whu.yt 阅读(119) 评论(0) 推荐(0) 编辑