K,L Domino
Lesson 3 of 3 in Coddy's Interview Coding Challenges - Pack IV course.
Challenge
HardWrite a function findDominoPair which gets an array of "dominos" arr and a target number k and a target number l.
Domino is a string which represent a pair of 2 integers, in the following format: "(3;5)"
The function should return true if two dominos "(a<sub>i;</sub>b<sub>i</sub>)" and "(a<sub>j;</sub>b<sub>j</sub>)" exists in arr and a<sub>i</sub> + a<sub>j</sub> = k and b<sub>i</sub> + b<sub>j</sub> = l, otherwise return false.
Example,
Input - arr = ["(1;3)", "(2;4)", "(3;1)", "(2;2)"], k = 5, l = 3
Expected output - true
Explanation - The pair "(3;1)" and "(2;2)" which exists in arr suffice, 3 + 2 = 5 and 1 + 2 = 3.
Note: arr is not sorted array and you can assume dominos non rotatable.
Try it yourself
#include <stdbool.h>
bool findDominoPair(char** arr, int arrSize, int k, int l) {
// Write code here
}