Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <inttypes.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdbool.h>
- /*
- * Given a list of strings, find the list of characters that appear in all strings.
- * Here's an example:
- * input = ['google', 'facebook', 'youtube']
- * output = ['e', 'o']
- */
- uint32_t common_characters(const char** strings, const uint32_t* lengths, const uint32_t n, char** output) {
- return 0;
- }
- int main() {
- const int32_t n = 3;
- const char *(strings[]) = { "google", "facebook", "youtube" };
- uint32_t lengths[n];
- for (int32_t i=0; i<n; ++i) {
- lengths[i] = strlen(strings[i]);
- }
- char* output = NULL;
- uint32_t n_chars = common_characters(strings, lengths, n, &output);
- for (uint32_t i=0; i<n_chars; ++i) {
- printf("%c ", output[i]);
- }
- printf("\n");
- free(output);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement