DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Mastering Go-Templates in Ansible With Jinja2
  • Performance Comparison — Thread Pool vs. Virtual Threads (Project Loom) In Spring Boot Applications
  • What Is JHipster?
  • Building the World's Most Resilient To-Do List Application With Node.js, K8s, and Distributed SQL

Trending

  • Mastering Go-Templates in Ansible With Jinja2
  • Performance Comparison — Thread Pool vs. Virtual Threads (Project Loom) In Spring Boot Applications
  • What Is JHipster?
  • Building the World's Most Resilient To-Do List Application With Node.js, K8s, and Distributed SQL
  1. DZone
  2. Culture and Methodologies
  3. Career Development
  4. Java Interview Question; Anagram of a Palindrome

Java Interview Question; Anagram of a Palindrome

Peter Lawrey user avatar by
Peter Lawrey
·
Dec. 14, 11 · Interview
Like (0)
Save
Tweet
Share
12.00K Views

Join the DZone community and get the full member experience.

Join For Free

In many interview questions, what they are looking for is a simple solution to an apparently complex problem. Unfortunately, the solutions are usually obvious if you know the solution, but very hard to come up with in an interview situation. ;)

 

Anagram of Palindrome

Write a method to test if a String is an anagram of a palindrome. The method should have O(n) time complexity and O(1) space complexity. You can assume all letters are between ' ' (space) and 'z'. Assume only letters matter and case is ignored.

e.g.
"kayak"
"Rats live on no evil star"
"A man, a plan, a canal, Panama"
"Doc, note: I dissent. A fast never prevents a fatness. I diet on cod."

 

The solution

A brute force approach is to generate anagrams and test if they are a palindromes. This is not required. All you need to test is if the String is the sort of string which can be turned into a palindrome.

Sample solution be given Thursday 15th.

 

From http://vanillajava.blogspot.com/2011/12/java-interview-question-anagram-of.html

Interview (journalism) Java (programming language)

Opinions expressed by DZone contributors are their own.

Trending

  • Mastering Go-Templates in Ansible With Jinja2
  • Performance Comparison — Thread Pool vs. Virtual Threads (Project Loom) In Spring Boot Applications
  • What Is JHipster?
  • Building the World's Most Resilient To-Do List Application With Node.js, K8s, and Distributed SQL

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: