Hi Pls help me to write first non-repeated char in string . eg. If string is abcda then first non-repeated char is b . I want an efficient algo / program which will traverse the string only n times . I don't want to use hash which set bit if it encounters char .
varsha_saxena 0 Newbie Poster
Recommended Answers
Jump to PostI hope that your code isn't supposed to be valid C, because it's not.
>But he wanted me to give a solution without using 2 - dimensional arrays.
Well, you can do it with a frequency table, which is essentially a one dimensional array:char FirstNonRepeated …
Jump to Post>What exactly is this line doing?
It's using a character in the string as an index into the saved array and incrementing the value stored there. The values start at zero, so you're basically counting how many of each character is stored in the string. Let's say for the sake …
All 6 Replies
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
varsha_saxena 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
Aia commented: I learned with this example +1
Aia 1,977 Nearly a Posting Maven
Narue 5,707 Bad Cop Team Colleague
varsha_saxena 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.