ruv1nce / 42-exam_intermediate

School 42 Silicon Valley intermediate exam questions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

42-exam_intermediate

All solutions except clone_list_n2 passed 42 examshell in April 2019

strings

count_alpha
Count each letter's occurences in a string and print it out.

infin_add
Add (and subtract) two numbers of potentially infinite lengths.

infin_mult
Multiply two numbers of potentially infinite lengths.

is_anagram
Determine if one string is an anagram of the second.

longest_subarray
Find the longest substring with an equal amount of even and odd digits.

ord_alphlong
Sort words by length and alphabetical order.

str_maxlenoc
Find the longest common substring in n strings.

numbers manipulation

count_of_2
Count, how many times digit '2' appears in all numbers up to n.

equation
Find all possible digit combinations for a simple equation.

find_pivot
Find an index of the array, if it exists, where sum of all the previous values is equal to sum of all the following values.

print_doublon
Given two sorted arrays, print numbers present in both.

linked lists

clone_list
Duplicate a linked list with each node containing a random pointer.
O(n2): naive solution. Timeouts in examshell.
O(n*logn): better solution, leaving the list unmodified.
O(n): fastest solution, involving original list modification and then restoring.

intersection
Determine if two linked lists intersect.

is_looping
Determine if the list has a loop.

queue
Implement queue data structure.

stack
Implement stack data structure.

trees

can_split
Find out if it's possible to cut the tree in two trees with the same number of nodes.

convert_bst
Convert a binary search tree into a doubly-linked list in-place.

height_tree
Calculate the number of edges on the longest path from the root to a leaf.

longest_sequence
Find the longest path in a tree comprising of nodes with consecutive values.

perimeter
Print the perimeter of a tree.

reverse_tree
Flip a tree horizontally.

width_tree
Find the longest possible path in the tree from a leaf to a leaf.

recursion

count_island
Read a map from file and flood-fill n islands on the map.

flood_fill
Flood-fill an island on a map.

g_diam
Find the longest path in an unweighted undirected graph.

range_comb
Generate premutations.

dynamic programming

gold_gain
Maximize the loot of a miner in a gold mine.

other

volume_histogram
Calculate how many units of water can a histogram hold if it was poured across the top.

About

School 42 Silicon Valley intermediate exam questions


Languages

Language:C 100.0%