## Cracking the Coding Interview Q1.2 原

jdflyfly

My Solution:

``````#include<stdio.h>
#include<string.h>

/**
* reverse the string in place.
*/
void reverse(char* str) {
if (str == NULL)
return;
int n = strlen(str);
char tmp;
//be careful: i<n/2, not i<=n/2;
for (int i = 0; i < n / 2; i++) {
tmp = str[i];
str[i] = str[n - 1 - i];
str[n - 1 - i] = tmp;
}
return;
}

int main() {
char str[10] = "abcde";
reverse(str);
printf("%s\n", str);

}``````

Solution:

``````void reverse(char *str) {
char * end = str;
char tmp;
if (str) {
while (*end) {
++end;
}
--end;
while (str < end) {
tmp = *str;
*str++ = *end;
*end-- = tmp;
}
}
}``````

### jdflyfly

java:数据结构（二）栈的应用（括号匹配）

dark_Souls
02/18
0
0
[Leetcode] Balanced Binary Tree

04/18
6
0
Cracking the Coding Interview Q1.1

My Solution: package chapter1; /** * Implement an algorithm to determine if a string has all unique characters. * What if you can not use additional data structures? * * @author......

jdflyfly
2014/04/08
56
0
Cracking the Coding Interview Q1.3

My Solution: package chapter1; /** * Write a method to decide if two strings are anagrams or not. * * @author jd * /public class Q1_3 { /* * Assume the char set is extended ASCI......

jdflyfly
2014/04/08
19
0
Cracking the Coding Interview Q1.4

My Solution: package chapter1; /** * Write a method to replace all spaces in a string with ‘%20’. (Assume string * has sufficient free space at the end) * * @author jd * /publ......

jdflyfly
2014/04/08
117
0

1、类和对象 类是对象的蓝图和模板，而对象是实例；即对象是具体的实例，类是一个抽象的模板 当我们把一大堆拥有共同特征的对象的静态特征（属性）和动态特征（行为）都抽取出来后，就可以定...

huijue

8
0
redis异常解决 ：idea启动本地redis出现 jedis.exceptions.JedisDataException: NOAUTH Authentication required

10
0
Spring 之 IoC 源码分析 (基于注解方式)

25
0
Docker安装PostgresSql

Docker安装PostgresSql 拉取docker镜像 # docker pull postgres:10.1010.10: Pulling from library/postgres9fc222b64b0a: Pull complete 38296355136d: Pull complete 2809e135bbdb: Pu......

Tree

8
0

20
0