上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 98 下一页
摘要: 1.5 利用字符重复出现的次数,编写一个方法,实现基本的字符串压缩功能。比如,字符串”aabcccccaaa“会变成”a2b1c5a3“。若”压缩“后的字符串没有变短,则返回原先的字符串。类似 leetcode中解法:Count and say.C++实现代码:#include#includeusi... 阅读全文
posted @ 2014-12-03 17:06 Jessica程序猿 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1.4 编写一个方法,将字符串中的空格全部替换为“%20“。假定该字符串尾部有足够的空间存放新增字符,并且知道字符串的”真实“长度。C++实现代码:#include#include#includeusing namespace std;string replacespace(string str){... 阅读全文
posted @ 2014-12-03 16:23 Jessica程序猿 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 1.3 给定两个字符串,请编写程序,确定其中一个字符串的字符重新排序后,能否变成另一个字符串。C++实现代码:#include#include#includeusing namespace std;bool isEqual(string s1,string s2){ map mp; if... 阅读全文
posted @ 2014-12-03 15:47 Jessica程序猿 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 1.2 用C或C++实现void reverse(char *str)函数,即反转一个null结尾的字符串。C++实现代码:#include#includeusing namespace std;/*反转字符串*/void reverse(char *str){ if(!str) ... 阅读全文
posted @ 2014-12-03 11:51 Jessica程序猿 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 1.1 实现一个算法,确定一个字符串的所有字符是否全部不同。假设不允许使用额外的数据结构,又该如何处理?C++实现:#include#include#includeusing namespace std;/*判断是否有重复字符*/bool unqString(string s){ if(s.e... 阅读全文
posted @ 2014-12-03 11:07 Jessica程序猿 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 这里主要谈及强连通分量(以下简称SCC,strongly connected component)三种常见的求法(以下涉及的图均为有向图),即Kosaraju、Tarjan和Gabow。三种算法背后的基础思想都是DFS,只是它们通过DFS获得了不同的信息。各位大哥大姐继续往下读之前,最好对DFS相关... 阅读全文
posted @ 2014-12-02 22:17 Jessica程序猿 阅读(3726) 评论(0) 推荐(0) 编辑
摘要: Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文
posted @ 2014-12-02 16:33 Jessica程序猿 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文
posted @ 2014-12-02 14:11 Jessica程序猿 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such possibl... 阅读全文
posted @ 2014-12-02 11:20 Jessica程序猿 阅读(286) 评论(0) 推荐(0) 编辑
摘要: You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenati... 阅读全文
posted @ 2014-12-02 09:35 Jessica程序猿 阅读(237) 评论(0) 推荐(0) 编辑
上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 98 下一页