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 7088087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:45:16+00:00 2026-05-28T07:45:16+00:00

I am designing a problem in which I want to find how many times

  • 0

I am designing a problem in which I want to find how many times a given string can be found (formed) from another base string with one character used only once.

Suppose I have

string str = "COMPUTER";

string basestr = "**TER** WITH **R** LABEL **COMPUTER** BELONGS TO **COMPUT** QUICK CUTE **COM** FOX JUM **P** S **U** R **T** H **E** LAZY DOG";

So want that my program returns 3 for this sting basestr.
Here one COMPUTER is clearly available, another is in two words and last is in words and characters.

Please help me program this ?
How can I do that ?
Thanks

  • 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-28T07:45:17+00:00Added an answer on May 28, 2026 at 7:45 am

    First, construct character counts for the short string. Then construct character counts for the long string. For each character count of the short string, divide the count from the long string by the count of the short string, keeping only the integer part. Pick the smallest integer – it is the answer to your problem.

    int[] Count(string s) {
        int[] res = new int[256];
        foreach (var c in s) {
            res[c]++;
        }
        return res;
    }
    int ShortInLong(string ss, string ls) {
        var sc = Count(ss);
        var lc = Count(ls);
        int res = int.MaxValue;
        foreach (var c in ss) {
            int d = lc[c] / sc[c]; // sc[c] is never 0 because of the way we constructed it
            res = Math.Min(res, d);
        }
        return res;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is inspired from another topic which poses this question: Find the first
I'm currently designing a custom tab control class which derives from System.Windows.Forms.Control. The problem
I am designing a prank app for android in which i want to show
This is just a very simple question to which i can't find a good
The Problem: I am designing a site which uses the same sidebar on all
I am designing a usercontrol which acts as a drawer which I want to
I've recently encountered a problem designing a web page. I needed to have rounded
I'm re-designing a Web site and I have a problem with the existing data
This is a problem I didn't forsee when designing the structure of my applicaton.
while designing my user control, i encountered the following problem: i would like to

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.