Technical Code Interview Prep Notes

Data Structures and Algorithms

Question 1: How do you reverse a linked list using recursion (Java)?

I found the answer on this stackoverflow post “Reversing a linked list in Java, recursively”. This can be solved answering the following questions:

  1. What is the reverse of null (the empty list)? null.
  2. What is the reverse of a one element list? the element.
  3. What is the reverse of an n element list? the reverse of the second element on followed by the first element.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 public ListNode Reverse(ListNode list) {
    // What is the reverse of null (the empty list)? null.
    if (list == null) return null;

    // What is the reverse of a one element list? the element.
    if (list.next == null) return list;

    // What is the reverse of an n element list? the reverse of the second element on followed by the first element.
    // so we grab the second element (which will be the last after we reverse it)
    ListNode secondElem = list.next;

    // bug fix - need to unlink list from the rest or you will get a cycle
    list.next = null;

    // then we reverse everything from the second element on
    ListNode reverseRest = Reverse(secondElem);

    // then we join the two lists
    secondElem.Next = list;

    return reverseRest;
}

Question 2: How do you find a length of a linked list?

Traverse through all the elements until you find the last node which points to null.

Question 3: How do you find the middle of a linked list using only one pass?

  1. Maintain two pointers as you traverse through the linked list.
  2. Increment Pointer 1 on every node and only increment Pointer 2 on every 2nd node.
  3. When you reach the end of the list, Pointer 2 will be pointing to the middle of the list.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class LinkedListTest {
    public static void main(String args[]) {
    // Creating LinkedList with 4 elements including head
    LinkedList linkedList = new LinkedList();
    LinkedList.Node head = linkedList.head();
    linkedList.add( new LinkedList.Node("1"));
    linkedList.add( new LinkedList.Node("2"));
    linkedList.add( new LinkedList.Node("3"));

    // Finding middle element of LinkedList in single pass
    LinkedList.Node current = head;
    int length = 0;
    LinkedList.Node middle = head;

    while(current.next() != null){
      length++;
      if(length % 2 == 0){
          middle = middle.next();
      }
      current = current.next();
    }

    if(length % 2 == 1){
      middle = middle.next();
    }

    System.out.println("Length of LinkedList: " + length);
    System.out.println("Middle element of LinkedList : " + middle);

    }
}

Read more here.

Question 4: Does a given linked list have a loop?

This is solved similarly to the question above “Question 3: How do you find the middle of a linked list using only one pass?”:

  1. Maintain 2 pointers as you traverse through the list.
  2. Increment Pointer 1 on every node and only increment Pointer 2 on every 2nd node.
  3. If Pointer 1 and Pointer 2 point to the same node, the list has a loop.

Question 5: An integer array has numbers from 1 to 100, there is a duplicate in the array. Find the duplicate.

  1. Add all the numbers stored in the array.
  2. Find the expected sum of all the numbers if there were no duplicates. The sum is represented by a formula n(n+1)/2.
  3. Subtract the actual sum from the expected sum. The answer is the dulicate number.
  4. This works if there is 1 duplicate in the array, for multiple duplicates use a Hash Map, where the number is the key and the the occurence is the value. Any values larger than 1 will reveal the duplicates.

Question 6: What is the difference between a Stack vs a Queue?

A Stack is LIFO (Last In First Out) structure and a Queue is a FIFO (First In First Out) structure.

Question 7: What is a Binary Search Tree?

They are also sometimes called ordered or sorted binary trees, are a class of data structures used to implement lookup tables and dynamic sets. They store data items, known as keys, and allow fast insertion and deletion of such keys, as well as checking whether a key is present in a tree. In a binary search tree:

  1. Every left node is smaller than the root element.
  2. Every right node is larger than the root element.
  3. There are no duplicates in the binary search tree.

Question 8: How would you sort and array using a Bubble sort?

Bubble sort is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. Worst Case performance is O(n^2), best case is O(n).

  1. Start comparing first and second element array[0] and array[1].
  2. If array[0] > array[1] then swap numbers e.g. array[0] = array[1] and array[1] = array[0].
  3. Repeat with the next two element, array[1] and array[2] and so on until you reach the end of the list
  4. This is referred as one pass and at the end of first pass largest number is at last.
  5. Repeat this comparison again starting from array[0] but this time going till second last pair only array[n - 1].

In a Bubble sort we need n - 1 iteration to sort n elements at end of first iteration largest number is sorted and subsequently numbers smaller than that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var array =[13,1,24,56,23,4,3,2,7,9,10,11];

console.log("Sorted Array: " + bubbleSort(array));

function bubbleSort(a){
  var swapped = true;
  for(var i = 0; i < a.length-1; i ++){
    swapped = false;
    for(var j = 0; j < a.length-1; j ++){
      console.log(i +" " + j);
      if (a[j] > a[j+1]){
        var temp = a[j];
        a[j] = a[j+1];
        a[j+1] = temp;
        swapped = true;
      }
    }
    if(swapped === false) return a; // if no swaps have been made, the array is sorted. No need to keep looping.
    }
  return a;
}

Question 9: How would you check if a number is a palindrome?

Using a modulo we can determine if a number is a palindrome:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var number = 2332; // example number
var orig_num = number; // keep a copy of the original number
var new_num = number; // this number will change as we try to reverse the number without using strings
var check_num = 0;
var check_is_palindrome =[]; // storing all the individual numbers here  as we get them in reverse order.
// console.log("Number to check: " + number);

function isPalindrome(number) {

    if (number === 0) return true;

    var num_of_passes = 0;

    while (new_num > 0){
        num_of_passes ++;
        remainder = number % 10;
        //console.log("Remainder: " + remainder);
        new_num = (number - remainder)/10;
        //console.log("New number: "+ new_num);
        number = new_num;
        check_is_palindrome.push(remainder);
        //console.log(check_is_palindrome);
        //console.log("Num of passes: " + num_of_passes)
    }

    var final_check_num = 0; // this is to save our result after reversing the number

    for (var i = 0; i < check_is_palindrome.length; i++){
        final_check_num += check_is_palindrome[i] * Math.pow(10,num_of_passes - 1);
        num_of_passes --;
        //console.log("Final_check_num: " + final_check_num);
      }

    return orig_num === final_check_num;
}

console.log("Is number " + number " a palindrome? " + isPalindrome(number));

Question 10: Describe a Selection Sort?

Selection sort is a sorting algorithm, specifically an in-place comparison sort. It has O(n^2) time complexity, making it inefficient on large lists. It performs worse than the similar insertion sort.

  1. Divide the list into two parts: the sublist of items already sorted and the sublist of items left to be sorted. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list.
  2. Find the smallest or largest element in the unsorted sublist.
  3. Exchange places with the leftmost unsorted item.
  4. Repeat 2 & 3 until no unsorted items left.

Question 11: Describe a Shell Sort?

The method starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared. Starting with far apart elements can move some out-of-place elements into position faster than a simple nearest neighbor exchange. It is similar to the Insertion sort that allows the exchange of items that are far apart. Worst case performance is O(n^2), best case is O(n log2 n). Picking the correct gaps is difficult, they should be reducing until the gap is 1.

Question 12: Describe an Insertion Sort?

Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

  1. For each item, remove form unsorted and place in the correct place in teh sorted list or sub-list
  2. Move up all larger elements if required to place the item in the correct place.

Question 13: Describe a Quick Sort?

This is an efficient sorting algorithm. The steps are:

  1. Pick an element, called a pivot, from the array.
  2. Reorder the array so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way).
  3. After this partitioning, the pivot is in its final position. This is called the partition operation.
  4. Recursively apply the above steps to the sub-array of elements with smaller values and separately to the sub-array of elements with greater values.
  5. The last element is ussually chosen as the pivot, but this will yeild a wort case complexity on an already sorted array or on an array of identical elements.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var array = [13,1,24,56,23,4,3,2,7,9,10,11];

console.log("Sorted Array: " + quickSort(array));

function quickSort(a) {
  var answer = [];
  if(a.length === 1) answer=a;
  if (a.length > 1){
    console.log("quicksort " + a);
    var pivot = a[a.length-1];
    //console.log(a.length);
    var left_a = [];
    var right_a = [pivot];
    for(var i = 0; i < a.length; i++){
      //console.log("Comparing " + pivot " and a[i]= " + a[i]);
      if(pivot > a[i]){
        left_a.push(a[i]);
      }
      if(a[i] > pivot){
        right_a.push(a[i]);
      }
      console.log(left_a, right_a);
    }
    answer.push(quickSort(left_a));
    answer.push(quickSort(right_a));
  }
  return answer;

Question 14: Describe a Merge Sort?

A merge sort is an O(n log n) comparison-based sorting algorithm. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945. Conceptually, a merge sort works as follows:

  1. Divide the unsorted list into n sublists, each containing 1 element (a list of 1 element is considered sorted).
  2. Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function merge_sort(list m)
    // Base case. A list of zero or one elements is sorted, by definition.
    if length(m) <= 1
        return m

    // Recursive case. Divide the list into equal-sized sublists.
    var list left, right
    var integer middle = length(m) / 2
    for each x in m before middle
         add x to left
    for each x in m after or equal middle
         add x to right

    // Recursively sort both sublists
    left = merge_sort(left)
    right = merge_sort(right)
    // Then merge the now-sorted sublists.
    return merge(left, right)

function merge(left, right)
    var list result
    while notempty(left) and notempty(right)
        if first(left) <= first(right)
            append first(left) to result
            left = rest(left)
        else
            append first(right) to result
            right = rest(right)
    // either left or right may have elements left
    while notempty(left)
        append first(left) to result
        left = rest(left)
    while notempty(right)
        append first(right) to result
        right = rest(right)
    return result

Question 15: Describe a Heap Sort?

Heap sort is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort.

HTML, CSS and JavaScript

Question 1: Explain what are selectors in CSS?

Selectors enable selecting an element to which a style is to be applied. There are different types of selectors, like class, id, descendant, type selectors.

Question 2: Explain a CSS box model?

Each element is represented as a rectangular box. Each of these boxes is described using the standard box model. Each box has four edges: the margin edge, border edge, padding edge, and content edge.

There are two types of box model, border-box and content-box.

Question 3: What are pseudo classes and what are they used for?

Pseudo classes are similar to classes, but they are not defined in the markup. Some examples are :link, :visited, :hover, :active, :first_line. They are used to call a specific action on an element, for example changng the link colour after it is visited, or changing a link colour when it is hovered.

Question 4: How do you optimize a website’s assets?

Some of the ways to optimize assets are:

  1. Make fewer HTTP requests
  2. Use a Content Delivery Network
  3. Add an Expires header
  4. Gzip components
  5. Put CSS at the top
  6. Move scripts to the bottom
  7. Make JavaScript and CSS external
  8. Minify JavaScript
  9. Remove duplicate scripts

Question 5: What are the 3 different ways to apply CSS?

  1. Inline
  2. External
  3. Embedded/Internal

Question 6: How is the float property implemented in CSS?

Floats allow an element to be positioned horizontally, allowing elements below the floated element to flow around it. Several floating elements can be placed together to make a gallery type layout. To prevent subsequent elements from flowing around the floated element, pass in the clear property, followed by the side you wish to disable (i.e., ‘left’, ‘right’, ‘both’).

Question 7: What is the purpose of the z-index and how is it used?

The z-index helps specify the stack order of positioned elements that may overlap one another.

Question 8: What’s the difference between standards mode and quirks mode?

One prominent difference between quirks and standards modes is the handling of the CSS Internet Explorer box model bug. Another notable difference is the vertical alignment of certain types of inline content.

If the browser decides that the document is modern, it’ll render it in standards mode. This means that, as a rule, CSS is applied in accordance with the CSS2 specification. If the browser decides that the document is old-school, it’ll render it in quirks mode.

Question 9: Graceful degradation vx progressive enhancement?

Graceful degredation - making sure that everythign still works to some level in an older browser, providing with basic functionality of the site.

Progressive enhancement - starting off with the oldest browsers in mind and adding in better functionality for browsers that can handle it.

Degrading gracefully means looking back whereas enhancing progressively means looking forward whilst keeping your feet on firm ground.

Useful Resources:

  1. Mozilla Developer Network.
  2. Wikipedia.
  3. StackOverflow.
  4. Tuts+.
  5. Java Revisited Blog.
  6. Quirks Mode.
  7. Google Developers.
  8. Skilled Up
  9. Quirks vs Standard
  10. Excellent resource of front end interview questions.
  11. HTTP2

🔥 If you enjoyed this post then you can keep up to date with my latests blogs posts & courses by following me on Twitter and checking out my code school for some hands on guided coding practice.

Cancun to Belize City by Bus

After 3 weeks in Cuba, Cancun was a refreshing change. The weather changed for the worse in Havana and our entire stay was overcast and grey so feeling warmth and sun on your skin again was excellent! We were a few hours in into our 24 hr trip from Havana (Cuba) to Columbia San Pedro (Belize) where we will be spending 3 educational weeks on an organic permaculture farm in the Belizian rainforest. After long wait at security in Cancun Airport we set off to find the ADO bus counter to book our tickets for that night to get to Belize City. Of course, as luck would have it, the bus was full for that night. This has shifted all of our plans by one day and left us homeless for the night. We booked our tickets for the next day in person at the ADO bus counter at the Cancun airport and spent the next few hours searching for somewhere to stay.

I wanted to share the information I have learned about getting from Cancun to Belize City.

1. Buy or book ADO bus tickets

The buses form Cancun to Belize are operated by ADO (pronounced “aa-de-oo”). They conveniently have an ADO ticket counter as you are exiting the airport. Here you can pre-book your trip to Belize in person as no online booking is available for the bus to Belize (you can also pre-book the ticket in the ADO bus station in Downtown Cancun).

There is only 1 bus a day at 10pm (it arrives in Belize City at 8.30am) from the ADO bus station in downtown Cancun. If you are traveling form the Cancun airport you would have to take another bus (it costs 64 Peso and takes 1hr) or taxi to the downtown ADO bus station. I have snapped a recent picture of the bus times from the airport to downtown Cancun:

Image of bus times from Cancun airport to downtown

Luckily we found somewhere to stay within a 5 minute walk of the ADO downtown bus station and after a much needed rest we carried on our journey the next evening.

2. Take the bus from Downtown ADO bus terminal

You have to arrive at least 15 minutes before the bus departure time, so to be safe we were waiting at the ADO bus station from 9:30 pm onwards. Bonus tip there is free wifi at the station!

Listen for the announcements and the bus arrived to gate 1 on time, we took our bags with us and loaded them into the special compartment just before getting on.

Image of ADO bus

The bus itself is air conditioned and it is absolutely freezing, so bring a blanked (not a joke! it was way too cold to fall asleep and it is apparently a well known fact). If you don’t fancy using the bus toilet you can get off at any of the stops and use the bathroom, usually the driver stops for about 5 minutes or so to pick up more people in Playa Del Carmen, Tulum, Bacalar and then Belize City.

3. Crossing the border

We arrived at the Mexican border at about 4am where we all had to get off the bus and queue outside to go through border control, they checked passports and collected the immigration slip that you would have filled out on entering the country. This is also where we had to pay Mexican Border Exit Tax which was about 300 MXN.

After about an hour at the border we were ushered back onto the bus and a short ride later we arrived at the Belizian border. Here we had to get off the bus with all our luggage and cross the border into Belize and scan all our luggage. Another hour later we were free to go back to sleep but not for long as we would be arriving into Belize City at 8.30am with a few stops on the way (Corozal and Orange Walk).

4. Arriving in Belize City

The bus terminal is still commonly known as Novelo’s (this is the name of a former bus company). The ADO buses arrive and depart from here along with a few other buses.

Image of Novelo Bus Terminal

From Belize City out journey to reach an organic farm cituated in the Belizian rainforest carries on still onto a small town of Punta Gorda in Southern Belize, but that is a whole other blog post.

Food in Havana

On our arrival we quickly realised that we were luckily not staying in the tourist area and that meant all the food near us would be in local Peso and super cheap! We had a chance to try a whole lot of pizza from little hole-in-the-wall places and decided on our favourite spots to have pizza in Havana.

There are 2 that stand out the most: a little blue window on San Lazaro just past Aramburu street and a small place on the Boulevard (not the one in Old Havana, but the one behind the Capitolio) it is right next to some benches and a sandwich place which seems to share the same kitchen, this one is the only one we have seen to make full sized pizzas and to actually fully utilise all available ingredients in Cuba to make tasty pizzas rather than a 2 ingredient pizza available almost everywhere else. Unfortunately I don’t have a picture of either of the places as I was too busy enjoying the food. But this is what the small pizzas look like:

Pizza Jabon y Queso Image

Apart from pizza, there have been a few good meals. Mostly in small local places where the main dish is usually Chuleta or Lomo with rice (usually it is a smoked pork cutlet), sometimes there is also pasta, but ususally it is just that - pasta with not much else.

One evening we walked past what looked like a little pub/bar called El Pachanguero and luckily decided to try it out. The food was not bad compared to most other places and prices reasonable (they accepted CUC and Pesos). There are not many places with “good” food in Cuba to be honest.

El Pachanguero Image

El Pachanguero Image

El Pachanguero Image

Havana, Cuba

Havana is a beautiful city, well worth seeing. It is however very easy to leave with a wrong impression about Havana, on one side you have Old Havana which is extremely well kept and touristy and beautiful but you also have the side of Havana that the locals live in which is much bigger and well worth seeing.

On our journey to Trinidad we found out that there is a China Town in Havana, so on our second day we set out to find it. This is definitely the most disappointing China Town I have ever been to, but at least it had an arch:

China Town Havana Image

Some of the buildings had the original Chinese signs and design, but very few and we only found about 3 places that even do chinese food. Given all that we skipped getting chinese and headed off towards the Capitolio in search of beans and rice.

Capitolio Havana Image

Capitolio is a must see, it is grand and this is where you can find all the old cars parked and ready to give you a ride or a tour of the city. If you don’t fancy that you can simply enjoy the view in the nearby park, by the Jose Marti Monument:

Jose Marti Monument Havana Image

This is a nice place to relax in the evening before heading into Old Havana:

Old Havana Image

We spent a few evenings walking around Old Havana, it is full of beautiful old buildings but it is also full of tourists and people trying to sell you stuff.

Our daily walk back from all the sightseeing took us through the Malecon, this is a nice walk in the sunshine but beware of the waves soaking you on windy days. The view of the city is incredible and if you have time it stretches for hours and takes you through a couple of interesting monuments:

Malecon Havana Image

And some quirky newer buildings:

Colourful Building Image

Abandoned Havana, Cuba

There is a huge amount of abandoned buildings in Havana, everywhere you look you can find remains of something that used to be impressive and gorgeous. I think they are still beautiful in their own haunting way. This is a side of Havana that is easy to miss if you stick to touristy places and take a taxi everywhere.

We found this one while walking through the little residential streets in Old Havana. This is the most looked after part of the city but the residentials streets have not seen any TLC for a some time.

Abandoned Building, Havana Image

This one is a huge construction site at the beginning of the El Prado, but looks like any work has been abandoned long ago.

Abandoned Building, Havana Image

Not far is this ovegrown house just before one of the squares in Old Havana.

Abandoned Building, Havana Image

We found this gorgeous mansion while exploring the Bodega area of Havana. It looks liek it has been a school at some point.

Abandoned Building, Havana Image

And my favourite of them all is the glorious huge tree growing out of the building near the Hemingway’s Daiquiry place in Old Havana.

Tree growing on top of a building Image

Cuban Food

While I can easily say I am a fan of Cuban food, I can imagine I would have had a different opinion had I not been eating with my family. Typical meals would include rice and peas, fried plantain and smoked pork steak with some sort of fruit drinks like guava juice or pina colada. Breakfast is usually an omlette sandwich or cheese and ham sandwich (they come in a burger type bun and are called bocaditos). Street food or hole in wall places and definately more popular here than the restaurants, and we unfortunately found out why. Our attempts to eat out have not been very successful, first of all there aren’t many restaurants in Cienfuegos but the ones we did try were extremely overpriced for what they were and not tasty in the slightest. Most popular food to buy on the go seems to be Bocaditos (sometimes toasted) and Pizza with most common fillings being Jamon (ham) and Queso (cheese), sometimes pineapple made an appearance. Cubans like sweet drinks and one of the popular ones are:

  • Guarapo (sugar cane drink which is very sweet and green in colour).
  • Pina Colada
  • Guava Juice
  • Pineapple Juice
  • Mango Juice
  • Coconut Milk
  • Malta (malt fizzy drink)
  • Garapina (fermented pineapple drink)

The hole in the wall places were not only better but also much cheaper as they took Pesos (Moneda Nacional) rather than CUC (Convertable Peso, used for tourists and more expensive places $1 CUC is around $25 Peso). You can exchange CUC to Peso in the foreign exhange offices (called Cadeca). Local Peso was pretty useful for buses, snacks and any small locals cafes. To give you some idea of the prices:

  • Pizza: $5 - $10 Peso
  • Bocadito: $5 - $10 Peso
  • Pork Kebab/Bochanero: $1 CUCq
  • Coffee: $1 Peso or 1 CUC depending where you go
  • Refresco: $10 Peso
  • Cocktails/Beer: 1 CUC - 2 CUC
  • Restaurant meal: 5 CUC - 10 CUC

There only two places to recommend really:

  1. El Rapido (the Cuban version of a McDonalds) - can be found on the Malecon, the Boulevard and near the hospital.
  2. Cafe by the Pier - great pork kebab and pina colada, also nice croquetes and an excellent view. Sometimes they have Cuban music/dancing on weekends.

Photos

El Rapido Image

Pineapple and Pork Kebab and Pina Colada Image

Casa Particular Breakfast Image

Cuban Dinner with Fried Fish Image

Pizza Jabon y Queso Image

Giron, Cuba

Giron is a beach and small town in the Bay of Pigs located on one of the worlds largest wetlands.

Getting There

We travelled there by car as the whole family wanted to come along to the amazing coral reefs but there are also some buses going to Havana (especially Viazul) stop in town and from there it is a short journey by taxi to all the attractions.

Attractions

1. Playa Giron

This is a small and gorgeous beach perfect for relaxing and bathing, it was not busy at all when we went and there is a small drinks shack one one end of the beach serving up cocktails and fresh coconuts.

Playa Giron Image

2. Cueva de los Peces

This is a 70m deep flooded cenote. It is full of brightly colourded tropical fish which can be seen while snorkeling or diving if you want to go deeper into the darker waters below. The sea water here mixes with fresh water giving it a sligtly unfamiliar feel.

Giron Lake Image

3. Coral Reefs

Just outside the park with the Cueva de los Peces across the road is a small beach full of coral reefs. Perfect for snorkeling or even diving and you can take diving lessons here as well.

Giron Reef Beach Image

4. Bay of Pigs Museum

Museo Playa Giron (Bay of Pigs Museum) in Cuba is dedicated to the Bay of Pigs invasion. The museum itself is small and houses a collection of photographs and other historic pieces relating to the invasion. It also has some military vehicles on display.

Giron Museum Image

Giron Tank Image

I could’t resist brtinging the family dog along, his name is Marley (after Bob Marley). I think he enjoyed Giron too!

Marley Image

Marley Image

Marley Image

Overall Giron is an excellent day trip, and is definitely unforgettable.

Trinidad, Cuba

While in Cuba we couldn’t leave without seeing Trinidad, it has been one of UNESCOs World Heritage sites since 1988. This small town with colonial architecture is very charming and popular with tourists. I have visited it briefly on my last trip to Cuba and by briefly I mean drove through it in a car, so I definitely needed to return.

We only stayed 3 days but it was enough to see everything Trinidad has to offer and even laze about on a beach.

Getting There

There are 3 ways to get to Trinidad from Cienfuegos: car, tourist bus and local bus. Plenty of cars were offering to take us there, as you near the bus station in Cienfuegos the chorus of drivers yelling out destinations is a little overwhelming. But once you push through all that, you end up inside a busy bus station. The times and destinations are hard to work out unless you know where to look (usually a piece of paper with writing on it stuck to the wall somewhere), but mostly you need to listen out for the driver yelling out the destinations. People with tickets board first and everyone else is crammed in later until there is no room to breathe. Knowing all that we opted for the tourist bus, which has guaranteed seats and air conditioning].

The tourist bus operator is Viazul and usually has it’s own section at the bus stations where you can purchase tickets and board the buses. Here is the timetable hanging on the ticket office door as of November 2014 in Cienfuegos bus station:

Cienfuegos to Trinidad Viazul Timetable Image

Make sure to arrive half an hour early as there is a queue for the tickets and the buses don’t run on time, they can be early or late by 15 minutes or more. Best bet, arrive early and sit tight!

Once we boarded the bus we realised the small chance of the bathroom on board being in working order was actually 0, not only that but the smell was funky the entire trip. The whole bus full of tourists holding their noses was not quite what we were after but the driver did something in the end which fixed it. Hooray!

Make sure to check return times when you reach your destination, these were not written anywhere and I had to ask the person selling the tickets.

Attractions

1. Playa Ancon

This lovely beach is not far from town, it is easily accessible by a taxi or you can take the mini bus. The beach is lined with hotels, so if you want to use the loungers you can get a drink. Otherwise if you keep walking towards the middle of the beach, you will find the public beach area.

Trinidad Beach Image

Trinidad Beach Image

2. Plaza Mayor

This basically an open air museum of Spanish colonial architecture, the small square has bars and restaurants but the popular attraction is the steps and the music bar/cafe at the top of the steps which comes to life later at night. There is live music and salsa dancing. Pina Colada was pretty good!

Trinidad Image

3. Museums

The whole of Plaza Mayor is lined with museums. They all charge a few CUC for entrance and range from plates and old furniture on display to some with history of Trinidad. This is the view from one of the museums, where you can go up to the rooftop via an old and very narrow staircase. The view itself is worth it:

Trinidad Image

Trinidad Image

4. Colonial Streets

Simply wandering around anywhere in the center of Trinidad will present you with colourful Colonial buildings. A typical colonial street:

Trinidad Image

Trinidad Image

Trinidad Image

Accomodation

There are plenty of hotels in Trinidad, but we chose to stay in a locals home. These are called Casa Particulars and the one we stayed in was cheap and great location. I will try to find the name of it as my aunt booked it for us. Here is the tasty breakfast we had every morning ( this cost 3 CUC each ):

Trinidad Breakfast at the Casa Particular Image

Rancho Luna, Cuba

Rancho Luna Image

This is the nicest beach we have been to in Cuba so far. It has sand, fishes, coral reefs and a few bars and cafes. I would not count on using the bathroom unless you are willing to go to every place and ask if you could pay to use their bathroom. Once you get there the coral reefs are to your left (if facing the water) around the curve towards the hotel (which can only be seen once you turn the corner). You should see people snorkeling there and it is quite shallow where the reef is. If you don’t find it there are still fishes in the water out and about.

Getting There

You can get there by either taxi or local bus. There are also organised tours. We took the bus every time, it was an interesting experience in itself. The buses go from the main Cienfuegos Bus Station:

El PradoImage

We took the 10am bus every time, the next one is 11:30. They are not very frequent! The local buses accept local currency (Moneda Nacional ie Peso). One way trip cost us $1 Peso (once it was $2 Peso because the driver demanded it). The space is limited on these buses and people with tickets board first and the rest of the pasengers squeeze on. Note that as a tourist you probably won’t be able to acquire a ticket and will likely be redirected to the more expensive tourist bus. Simply follow the crowd and pay on board. Tube rush hour in London was nothing compared to this bus journey, it is hot, there is no space and the driver lets everyone on regardless of how much you are struggling to breathe. I had a rather large sweaty lady hugging me to keep stable with a very old man on the other side making pitiful noises every time someone leaned on him. Not the most comfortable bus ride but it is only about 20 minues or so throught the countryside. Get off once you see the sea and beach.

Getting back

Getting back is not very hard, exit the beach through the restaurants and car park. Once you reach the main road there is a rather large tree to your left. There are ussually people stadnign under it. This is the bus stop to get back, it is not sign posted in any way.

You can get back usign the local bus again or the private trucks. The trucks are a better but more expensive option, it is not as hot with much more available space and costs $10 Local Peso. The trucks are modified to become “buses” and come in all sorts of shapes and colours. There is ususally one around 15:30. Get the bus or the truck which every comes first, but the buses are less punctual than the trucks and the truck is actually a fun ride.

This is the view from the “bus stop”:

Rancho Luna Image

And here is our truck approaching:

Rancho Luna Image

I have been told that all buses and trucks from this stop go to Cienfuegos.

Things to Do in Cienfuegos, Cuba

Visit the Cienfuegos Pier

You can spend some time on the pier which has some nice views of the bay and some fishing boats. On weekends at night they sometimes have music and dancing.

Cienfuegos Pier Image

Cienfuegos Pier Image

Cienfuegos Pier Image

Get a nice pork kebab by the pier

Right by the pier you can relax in a cafe Muelle, which does awesome pork and pineapple kebabs and pina coladas.

Kebab Image

Spend an evening on the Malecon

Most of the locals spend evenings here chatting with friends and there are a few bars/cafes across the road too. You can simply stroll along the length of the Malecon or take a seat and watch the bay at night.

Cienfuegos Malecon Image

Visit an 18th Century Cementary

There are 2 gorgeous and very old cementaries in Cienfuegos, I only have pictures from one of them. The better one is much smaller and older with graves and statues dating back to 1800s you might get away with taking photos depending on what the caretaker agrees to. We had to pay a small fee to ba taken around ($10 local pesos). The caretaker was very knowlegeable about the history of different graves but only speaks Spanish.

The bigger cementary was a bit of a walk, I would recommend taking the bus if it is very hot. Bus number 3 stops there. The entrance is free and you can walk around the different paths to see the older statues and gravestones. This cementary is more modern and it is in much better condition.

Cementario Image

Walk along the El Prado

This is the main street which leads towards the Malecon, in the evening there are lots of people simple walking around or sitting with friends on one of the many benches. The street is lined with cafes, restaurants and bars. If you want to spend less, buy drinks and food form the hole in the wall places for national currency.

El PradoImage

Go shopping on the Boulevrad

There are a couple of small markets along here and some general grocery shops. There isn’t much to buy really but interesting to see anyway.

Market off the Boulevard Image

Day Trips

You can take day trips to multiple places around Cienfuegos:

  1. El Nicho - small waterfall.
  2. Rancho Luna - the nicest beach near here with fishes and coral reefs.
  3. Cienfuegos Fort/Castle - just past Rancho Luna there is an old fort/castle.
  4. Botanical Gardens.