Comcast Technical Interview Questions
Comcast Technical Interview Questions
Example
Input: "abracadabra"
Notes
• You need not to worry about the order of strings in your output array. Like for s =
"aa", arrays ["a|a", "aa"] and ["aa", "a|a"] both will be accepted.
• In any string in your returned array res, order of characters should remain the
same as in the given string. (i.e. for s = "ab" you should return ["a|b"] and not ["b|
a"].)
• Any string in the returned array should not contain any spaces. e.g. s = "ab" then
["a|b"] is expected, ["a |b"] or ["a| b"] or ["a | b"] will give the wrong answer.
Constraints:
•1
Example
Output: 3
Here are all the unique ways to express 9 as a sum of coins 1, 3 and 5:
1, 1, 1, 1, 1, 1, 1, 1, 1
1, 1, 1, 1, 1, 1, 3
1, 1, 1, 1, 5
1, 1, 1, 3, 3
1, 3, 5
3, 3, 3
Notes:
Every input will include a coin of value 1. This guarantees that a solution will
always exist.
Constraints:
●1
●1
●1
3. Sort a given singly linked list in ascending order.
Input Format:
There is only one argument named head, denoting the head of the given singly
linked list.
Output Format:
After sorting, return the head of the same linked list that is provided in the input.
Constraints:
Sample Input 1:
Sample Output 1:
Sample Input 2:
Sample Output 2:
Input: x = 72
Output: true
Explanation: Binary representation of 72 is 01001000.
There are no two consecutive 1's in binary representation
Input: x = 12
Output: false
Explanation: Binary representation of 12 is 1100.
Third and fourth bits (from end) are set.
Input:
n1 = 2 , n2 = 3
1
/\
2 3
Output: 1
Explanation:
LCA of 2 and 3 is 1.
7. Given a binary tree “B” with unique values, write a program to
find: 1. The longest consecutive sequence. 2. The length of the
longest path comprising connected nodes with consecutive values.
10
/ \
/ \
11 9
/\ /\
/ \ / \
13 12 13 8
Maximum Consecutive Path Length is 3 (10, 11, 12)
Note: 10, 9 ,8 is NOT considered since
the nodes should be in increasing order.
For example, lexicographically next permutation of “gfg” is “ggf” and the next
permutation of “acb” is “bac”.
Note: In some cases, the next lexicographically greater word might not exist, e.g,
“aaa” and “edcba”.