Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7518455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:45:11+00:00 2026-05-30T01:45:11+00:00

For example. bacdbecdfb First non-repetitive character would be ‘a’ , second would be ‘e’

  • 0

For example. bacdbecdfb

First non-repetitive character would be ‘a’ , second would be ‘e’ .

This was an interview question, I came up with using hashing to solve in 2 passes but the interviewer wanted it in one pass.
The hint he gave was that the maximum value of k can be 26.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:45:12+00:00Added an answer on May 30, 2026 at 1:45 am

    You have just 26 possible character, So you can create an array of int of size 26 and in this way you can find all non repeated characters (by traversing your input and increase related character number). another iteration is needed to find their order (also repeated or not in second iterate is possible, in first iteration you just set the numbers for characters, e.g a is in position 0 and seen 1 time).

    This known as counting sort.

    Edit: for doing this just in one path you need add extra information to your sorting data, in fact you should add first visited time, So you will have array of struct:

    struct data
    {
       int firstVisitedPosition;
       int visitedCount;
    }
    
    data[26] sorter = new data[26];// --> initialize it as the way said above.
    //Find all items in sorter with visitedCount=1 
    var justOnes = sorter.Where(x=>x.visitedCount == 1).ToList();
    Find minimum firstVisitedPosition:
    var minPos = justOnes.Min(x=>x.firstVisitedPosition);
    var minItem = justOnes.First(x=>x.firstVisitedPosition == minPos);
    

    be careful sorter has length 26, and also justOnes has length ≤ 26 so iterating them 100 times doesn’t related to input data iteration and has no problem, Also sorting or other actions all are constants.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example: <select id=myselect> <option value=A>First</option> <option value=B>Second</option> <option value=C selected=selected>Third</option> <option value=D>Fourth</option> </select> Using
Example: This is just\na simple sentence . I want to match every character between
Example from Using YAML with Python Original YAML file contains this # tree format
Example: The user login to the webpage => Click on a button This action
Example int *ptr; *ptr = 1000; can I catch memory access violation exception using
example: NSString *day = [[NSString stringWithFormat:@السبت];and i think the representation of this string in
Example I have this array: @packages = [2, [4, 2, 1], 4, [4,2], [5,
Example program: list links This example program demonstrates how to fetch a page from
example strings 785*()&!~`a ##$%$~2343 455frt&*&* i want to capture the first and the third
Example: <div style=font-size:15px;>first matched here</div> I want to have PHP find the information in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.