You will solve the following coding tasks (independent of each other). Provide clear input/output behavior and handle edge cases.
1) Longest non-repeating substring (length + substring)
Given a string s, find:
-
The
maximum length
of a substring with
no repeated characters
.
-
One
such substring achieving that maximum length.
Return (max_len, substring).
Clarifications / edge cases to handle:
-
s
can be empty.
-
If multiple substrings have the same max length, you may return any one (or specify a tie-break rule such as the leftmost).
2) Group strings by anagram
Given an array of strings strs, group the strings into lists where each list contains strings that are anagrams of each other.
Return the groups in any order.
Follow-up:
-
State and justify the time and space complexity of your approach.
3) Execute grid moves from a command string (case-insensitive)
You are on an infinite 2D grid starting at (0, 0). You receive a command string cmd consisting of characters representing moves:
-
U
/
u
: move up
(x, y+1)
-
D
/
d
: move down
(x, y-1)
-
L
/
l
: move left
(x-1, y)
-
R
/
r
: move right
(x+1, y)
Process the string in order and return the final coordinate (x, y).
Clarifications:
-
Commands should be treated
case-insensitively
(mixed upper/lower case may appear).
-
Define what you do with any invalid character (e.g., ignore it or raise an error).