You are given two independent coding tasks.
Implement a function that determines whether two given strings are anagrams of each other.
s
and
t
consisting only of lowercase English letters (
'a'
-
'z'
).
t
is an anagram of
s
. Two strings are anagrams if and only if they contain exactly the same characters with the same multiplicities, in any order.
Requirements:
bool areAnagrams(string s, string t)
.
You may assume:
0 <= len(s), len(t) <= 10^5
.
You are given the head of a singly linked list of integers. The nodes are indexed starting from 1 at the head, then 2 for the next node, and so on.
Reorder the list so that:
The reordering must be done in-place by changing the next pointers; do not allocate or copy list nodes.
ListNode* head
pointing to the head of a singly linked list.
Example:
1 -> 2 -> 3 -> 4 -> 5 -> null
1 -> 3 -> 5 -> 2 -> 4 -> null
Constraints:
[0, 10^5]
.