This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1.5 Implement a method to perform basic string compression using the counts of repeated characters. | |
* For example, the string aabcccccaaa would become a2blc5a3. | |
* If the "compressed" string would not become smaller than the original string, | |
* your method should return the original string. | |
* Learn this code that how to add the tips and notes | |
* this code is very good. | |
* | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1.4 Write a method to replace all spaces in a string with'%20'. | |
// You may assume that the string has sufficient space at the end of the | |
// string to hold the additional characters, and that you are given the "true" length | |
// of the string. | |
// (Note: if implementing in Java, please use a character array so that you can | |
// perform this operation in place.) | |
// EXAMPLE | |
// Input: "Mr John Smith " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Problem : 1.3 Given two strings, write a method to decide if one is a permutation of the other. | |
Language : JAVA | |
Solution: Assuming that the string only consist of ASCii letters. Because the ASCii has at most 256 letters. | |
So here we can simulate the hashing operation. | |
Record the appearing times of every character from the first string. | |
reduce the number of the asc array if the second string has the same character with the first string. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Problem: 1.2 Implement a function void reverse(char* str) in C or C++ which reverses a null-terminated string. | |
// CareerCup | |
// | |
// Solution: | |
Step1 : caculate the length of the string. | |
Step2 : using an additional char space to help swap the i-th position and the (length-1-i)-th position. | |
// Created by Guanyu Zhu on 6/17/14. | |
// Copyright (c) 2014 Guanyu Zhu. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Problem : 1.1 Implement an algorithm to determine if a string has all unique characters. Whatif you cannot use additional data structures? | |
Language : JAVA | |
Solution: Assuming that the string only consist of ASCii letters. Because the ASCii has at most 256 letters. | |
So here we can simulate the hashing operation. | |
To find out if one letter can appear twice in the string. | |
*/ |