链表相关算法题、编程题、面试题

字符串、数组相关编程题面试题

shizheng posted @ 2012年11月14日 02:22 in 算法与数据结构 , 1625 阅读

 

Implement an algorithm to determine if a string has all unique characters What if you can not use additional data structures? 

如何判断字符串中是否有重复的字符?

bool isUniqueChar(string s)
{
    bool h[256]={0};
    for (int i=0; i<=s.size()-1; ++i)
    {
        if (h[s[i]]) return false;
        h[s[i]] = 1;
    }
    return true;
}

 

 

如何将C的字符数组(char *)逆转?

Write code to reverse a C-Style String (C-String means that “abcd” is represented as five characters, including the null character ) 

 

void cStringReverse(char *s)
{
    char *end = s;
    char tmp;
    if (s)
    {
        while (*end) ++end;
        --end;
        while (s < end)
        {
            *s++ = *end--;
        }

    }
}

 

如何将字符数组重复的字符去除?不允许使用额外的存储空间。

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.

 

void removeDuplicateChar(char *s)
{
    char *end = s+1;
    char *p = s+1;
    if (s)
    {
        while (*p)
        {
            char *q = s;
            while (q < p)
            {
                if (*p == *q)
                {
                    break;
                }
                ++q;
            }
            if (p == q)
            {
                *end = *p;
                ++end;
            }
            ++p;
        }
        *end = '\0';
    }
}

 

Avatar_small
seo service UK 说:
2024年2月23日 19:39

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking

Avatar_small
แนะนำ เว็บบาคาร่า 说:
2024年4月01日 15:44

You have lifted a basic offspring..Blesss for using..I would need to think about better most recent exchanges from this blog..preserve posting..

Avatar_small
먹튀검증 说:
2024年4月01日 15:45

One present why galore businesses opt for postcards is because they are overmuch cheaper to be prefab and this can forbear a lot of expenses on the lengthened run. 

Avatar_small
먹튀검증 说:
2024年4月01日 15:46

It’s probably just as easy or difficult to make money online through a blog as it is selling information products like yours. The key to BOTH is the ability to create a following/list of loyal listeners. That’s the hard part! 

Avatar_small
헤이먹튀 说:
2024年4月01日 17:07

Another man complained that it wasn’t as much about the money, but the promise that he didn’t need to have any internet experience to be successful. I couldn’t find one satisfied buyer. There are many websites which solely in dedicated to Jeff Paul as a scam artist.

Avatar_small
토토팡 说:
2024年4月01日 17:08

You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this

Avatar_small
먹튀뱅크 说:
2024年4月01日 17:08

Superb web site, many thanks for finding the time to create these posts, i enjoy looking through all of them!

Avatar_small
메이저사이트모음 说:
2024年4月01日 17:45

That is the incredible mentality, in any case is simply not assist with making each sence at all proclaiming about that mather. Basically any strategy an abundance of thanks notwithstanding

Avatar_small
슬롯머신 说:
2024年4月01日 17:46

This article was written by a real thinking writer without a doubt. I agree many of the with the solid points made by the writer. I’ll be back day in and day for further new updates.

Avatar_small
토토사이트 说:
2024年4月01日 17:47

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here!

Avatar_small
카지노게임 说:
2024年4月01日 18:18

Hmm… As i fully grasp weblogs having a linked problem, all the same as i do not ended pictures web page. As i added in from the piece that can help populars moreover i’ll quite possibly possibly be people specific primer.

Avatar_small
안전토토사이트 说:
2024年4月01日 18:19

it’s really nice and meanful. it’s really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull

Avatar_small
메이저안전놀이터 说:
2024年4月01日 18:20

I had attempt to advance your own article in to delicius all things considered it’s anything but a predicament utilizing your data destinations would you be able to please reverify the thought. much appreciated again

Avatar_small
먹튀폴리스신고 说:
2024年4月01日 18:52

It’s probably just as easy or difficult to make money online through a blog as it is selling information products like yours. The key to BOTH is the ability to create a following/list of loyal listeners. That’s the hard part! 

Avatar_small
온라인카지노순위 说:
2024年4月01日 18:52

 Thank you very much and will look for more postings from you. I feel strongly that love and read more on this topic. If possible, such as gain knowledge, would you mind updating your blog with additional information? It is very useful for me.

Avatar_small
메이저토토사이트 说:
2024年4月01日 18:53

it’s really nice and meanful. it’s really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull

Avatar_small
먹튀검증사이트 说:
2024年4月01日 19:16

 Thank you very much and will look for more postings from you. I feel strongly that love and read more on this topic. If possible, such as gain knowledge, would you mind updating your blog with additional information? It is very useful for me.

Avatar_small
먹튀사이트조회 说:
2024年4月01日 19:17

Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates.

Avatar_small
안전놀이터모음 说:
2024年4月01日 19:18

They also need to be good communicators, as they will often need to explain their ideas to clients and contractors. In addition, interior designers should have a good understanding of how different materials and finishes can impact a space. 

Avatar_small
토토읕 说:
2024年4月01日 19:34

This article was written by a real thinking writer without a doubt. I agree many of the with the solid points made by the writer. I’ll be back day in and day for further new updates.

Avatar_small
검증나라 说:
2024年4月01日 19:34

it’s really nice and meanful. it’s really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull

Avatar_small
먹튀사이트조회 说:
2024年4月01日 19:34

You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this

Avatar_small
먹튀검증 说:
2024年4月01日 19:35

Hmm… As i fully grasp weblogs having a linked problem, all the same as i do not ended pictures web page. As i added in from the piece that can help populars moreover i’ll quite possibly possibly be people specific primer.

Avatar_small
꽁머니 说:
2024年4月01日 19:36

Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! 

Avatar_small
먹튀검증커뮤니티 说:
2024年4月01日 19:36

Actually an incredible expansion. I have perused this great post. Gratitude for sharing data about it. I truly like that. Much appreciated so part for your assemble.

Avatar_small
먹튀검증업체 说:
2024年4月01日 19:44

Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! 

Avatar_small
먹튀검증사이트 说:
2024年4月01日 19:45

That is the excellent mindset, nonetheless is just not help to make every sence whatsoever preaching about that mather. Virtually any method many thanks in addition to i had endeavor to promote your own article in to delicius nevertheless it is apparently a dilemma using your information sites can you please recheck the idea.

Avatar_small
스포츠토토 说:
2024年4月01日 20:45

I hope this helps almost anyone searching for this type of topic. I think this website is the best for such topics. Good work and quality of article. Major site

Avatar_small
안전놀이터 说:
2024年4月01日 20:45

Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! 

Avatar_small
가입쿠폰 说:
2024年4月01日 20:45

Hmm… As i fully grasp weblogs having a linked problem, all the same as i do not ended pictures web page. As i added in from the piece that can help populars moreover i’ll quite possibly possibly be people specific primer.

Avatar_small
사설먹튀검증 说:
2024年4月01日 21:08

You have lifted a basic offspring..Blesss for using..I would need to think about better most recent exchanges from this blog..preserve posting..

Avatar_small
메이저사이트 说:
2024年4月01日 21:08

One present why galore businesses opt for postcards is because they are overmuch cheaper to be prefab and this can forbear a lot of expenses on the lengthened run. 

Avatar_small
토토사이트검증 说:
2024年4月01日 21:08

One present why galore businesses opt for postcards is because they are overmuch cheaper to be prefab and this can forbear a lot of expenses on the lengthened run. 

Avatar_small
안전토토사이트 说:
2024年4月01日 21:26

It’s probably just as easy or difficult to make money online through a blog as it is selling information products like yours. The key to BOTH is the ability to create a following/list of loyal listeners. That’s the hard part! 

Avatar_small
카지노사이트추천 说:
2024年4月01日 21:26

Another man complained that it wasn’t as much about the money, but the promise that he didn’t need to have any internet experience to be successful. I couldn’t find one satisfied buyer. There are many websites which solely in dedicated to Jeff Paul as a scam artist.

Avatar_small
온라인카지노쿠폰 说:
2024年4月01日 21:27

You have lifted a basic offspring..Blesss for using..I would need to think about better most recent exchanges from this blog..preserve posting..


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter