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

  • Home
  • SEARCH
  • 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 8924005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:17:11+00:00 2026-06-15T07:17:11+00:00

I have two dictionary corresponding to character counts of two different strings. I want

  • 0

I have two dictionary corresponding to character counts of two different strings. I want to check if they are made up of same characters or not, regardless of the frequencies of the characters.


Say, I have two strings caars and racs
They are made up of same characters a,c,r,s


I know of cmp method to compare two dictionaries, which also compares both the key-value pairs. But I don’t want to compare their values or counts.


Just in case, you may ask, why do I have dict then for both the strings. Well, I do need them in some other part of the problem. So, why not use them.


How can I do this in python quickly?

  • 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-06-15T07:17:13+00:00Added an answer on June 15, 2026 at 7:17 am

    You want to use a set.

    In [32]: str1 = 'caars'
    
    In [33]: str2 = 'rats'
    
    In [34]: set(str1) == set(str2)
    Out[34]: False
    
    In [35]: str3 = 'racs'
    
    In [36]: set(str1) == set(str3)
    Out[36]: True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dictionary cannot have two values with same key. please tell which logic/algorithm being used
Resource dictionary 03-11-2010 10:56 AM | I have two different projects. I linked a
I need an XML-serializable dictionary. Actually, I now have two quite different programs that
I have two dictionaries with the same structure: Dictionary<string, int> foo = new Dictionary<string,
I have two dictionaries. When I change a value in dictionary 1, the same
I have two dictionary personalizePatientChartDictionary and personalizePatientChartDictionaryOriginal . Both have same key but value
I have two methods that do the same thing, one works with a Dictionary<object,
I have two different databases that contain two tables with the exact same design.
I have two dictionaries, that are of similar structure...meaning they(should) have the same key
I have Two Dictionary DictA & DictB such as: Dictionary<int, string> DictA = new

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.