Count the frequency of each character in the two strings. Check if the two histograms match. O(n) time, O(1) space (assuming ASCII) (Of course it is still O(1) space for Unicode but the table will become very large).
More Related Contents:
- Apply Quicksort to the list M,E,R,G,E,S,O,R,T
- How to determine if a point is in a 2D triangle? [closed]
- Data structures for loaded dice?
- Writing your own square root function
- Merge Sort a Linked List
- How do you like your primary keys? [closed]
- How to determine if a linked list has a cycle using only two memory locations
- Computing set intersection in linear time?
- Best word wrap algorithm? [closed]
- Circle-circle intersection points
- What is a bubble sort good for? [closed]
- Sorting in place
- Programming Riddle: How might you translate an Excel column name to a number?
- Given a number, produce another random number that is the same every time and distinct from all other results
- Hashing a Tree Structure
- Quicksort superiority over Heap Sort
- Best way of calculating n choose k?
- Why DFS and not BFS for finding cycle in graphs
- Finding multiple entries with binary search
- Painter puzzle – algorithmic estimation from first principles
- Polynomial time and exponential time
- Given a number, find the next higher number which has the exact same set of digits as the original number
- How to count integers between large A and B with a certain property?
- The best shortest path algorithm
- Why is depth-first search claimed to be space efficient?
- Algorithm for permutations of operators and operands
- How can I convert between a double-double and a decimal string?
- Optimized low-accuracy approximation to `rootn(x, n)`
- What are probabilistic data structures?
- Connected Component Labeling – Implementation