
cracking the coding
pipi666661
学习中。。。
展开
-
【Cracking the coding interview】Q1.4(变位词)
Write a method to decide if two strings are anagrams or not.写一个函数判断两个字符串是否是变位词。O(n)的算法,声明个数组来统计出现的次数#include #include #include using namespace std;bool isAnagram(string x, string y){原创 2013-12-23 19:43:23 · 628 阅读 · 0 评论 -
【Cracking the coding interview】Q1.1(字符唯一)
读了Hawstein大神的大作,读书笔记记录之,膜拜大神用,给自己增些知识。Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?实现一个算法来判断一个字符串中的字符是否唯一思路:用最小的数原创 2013-12-23 17:34:12 · 704 阅读 · 0 评论 -
【Cracking the coding interview】Q1.2(反转字符串)
原文:Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)写代码翻转一个C风格的字符串。(C风格的意思是"abcd"需要用5个字符来表示,包含末尾的 结束字符)思原创 2013-12-23 17:56:48 · 680 阅读 · 0 评论 -
【Cracking the coding interview】Q1.3(移除重复字符)
Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not原创 2013-12-23 19:18:20 · 540 阅读 · 0 评论 -
【Cracking the coding interview】Q1.6(旋转矩阵)
Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?一张图像表示成NxN的矩阵,图像中每个像素是4个字节,写一个函数把图原创 2013-12-23 20:21:04 · 548 阅读 · 0 评论 -
【Cracking the coding interview】Q1.7(矩阵置0)
Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.写一个函数处理一个MxN的矩阵,如果矩阵中某个元素为0,那么把它所在的行和列都置为0.#include #include #include using namespa原创 2013-12-23 21:44:04 · 767 阅读 · 0 评论 -
【Cracking the coding interview】Q1.8(旋转字符串)
Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring原创 2013-12-23 21:52:04 · 503 阅读 · 0 评论 -
【Cracking the coding interview】Q1.5(替换字符串)
Write a method to replace all spaces in a string with ‘%20’.写一个函数,把字符串中所有的空格替换为%20 。原创 2013-12-23 20:18:20 · 415 阅读 · 0 评论