Cracking The Coding Interview 1.1
//原文:
//
// Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?
//
// 使用一个数组来记录该字符是否出现过,这里假定只为小写字母。
#include <iostream>
using namespace std;
bool isUnique(const char *str)
{
int size = strlen(str);
bool isUnique[26] = {false};
for (int i = 0; i < size; i++)
{
int k = str[i] - 'a';
if (isUnique[k])
{
return false;
}
else
isUnique[k]=true;
}
return true; }
int main()
{ char s[] = "seoklncsz";
cout << isUnique(s) << endl;
return 0;
}
Cracking The Coding Interview 1.1的更多相关文章
- Cracking the coding interview
写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...
- Cracking the coding interview 第一章问题及解答
Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...
- Cracking the Coding Interview(Trees and Graphs)
Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...
- Cracking the Coding Interview(Stacks and Queues)
Cracking the Coding Interview(Stacks and Queues) 1.Describe how you could use a single array to impl ...
- 《Cracking the Coding Interview》读书笔记
<Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...
- Cracking the coding interview目录及资料收集
前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...
- 《Cracking the Coding Interview》——第13章:C和C++——题目6
2014-04-25 20:07 题目:为什么基类的析构函数必须声明为虚函数? 解法:不是必须,而是应该,这是种规范.对于基类中执行的一些动态资源分配,如果基类的析构函数不是虚函数,那么 派生类的析构 ...
- 《Cracking the Coding Interview》——第5章:位操作——题目7
2014-03-19 06:27 题目:有一个数组里包含了0~n中除了某个整数m之外的所有整数,你要设法找出这个m.限制条件为每次你只能用O(1)的时间访问第i个元素的第j位二进制位. 解法:0~n的 ...
- 二刷Cracking the Coding Interview(CC150第五版)
第18章---高度难题 1,-------另类加法.实现加法. 另类加法 参与人数:327时间限制:3秒空间限制:32768K 算法知识视频讲解 题目描述 请编写一个函数,将两个数字相加.不得使用+或 ...
- 《Cracking the Coding Interview 》之 二叉树的创建 与 遍历(非递归+递归version)
#include <iostream> #include <cstdio> #include <vector> #include <stack> #de ...
随机推荐
- Spring学习笔记(入门)
1.基本看了一下,spring就是利用这个框架帮助我们实例化对象的工具.首先我们需要引入jar包,pom.xml如下: <project xmlns="http://maven.apa ...
- ubuntu下安装Firefox中国版解决Ubuntu与Windows下Firefox账号同步问题(已解决)
1. 下载最新版本火狐Linux版 下载地址:http://firefox.com.cn/download/ 选择火狐Linux64-bit版,下载后文件为:Firefox-latest-x86_64 ...
- Practical Node.js (2018版) 第4章: 模版引擎
Template Engines: Pug and Handlebars 一个模版引擎是一个库或框架.它用一些rules/languages来解释data和渲染views. web app中,view ...
- 蓝鲸DevOps深度解析系列(1):蓝盾平台总览
关注嘉为科技,获取运维新知 2018年10月,嘉为科技与腾讯云.蓝鲸智云携手,在北京.上海.广州.深圳举办 “研运一体,数据驱动,让运维走向运营”为主题的分享会,来自金融.电力.能源.制造等行业的 ...
- vs2013+caffe+cpu
1.下载caffe官网提供的工具包,复制Windows下CommonSettings.props.example,后缀改为CommonSettings.props 2.由于电脑无GPU,所以修改复制过 ...
- 安装redisPHP扩展
1. "predis/predis":"~1.1@dev" 2.composer update 即可,这是给项目添加redis扩展 启动服务端 redis-se ...
- adb 获取包名
1.aapt dump badging 指定的路径 +包名 ======= adb logcat|findstr START 2.顶部和尾部有包名和activity
- MyBatis中mybatis-generator代码生成的一般过程
MyBatis框架的使用,可以参考我的文章: https://blog.csdn.net/JayInnn/article/details/81746571(基于Mybatis实现一个查库的接口) ht ...
- 5月13 jquery的一些应用
首先对于JavaScript的一些复习:操作内容,操作属性,操作样式 <title>无标题文档</title> <style> #aa { width:200px; ...
- Matlab-10:Ritz-Galerkin方法求解二阶常微分方程
一.代数多项式法: tic; clear clc % N=input('please key in the value of ''N'''); N=10; M=100; h=1/M; X=0:h:1; ...