Latest stories

HackerRank ‘CamelCase’ Solution


Short Problem Definition: Alice wrote a sequence of words in CamelCase as a string of letters, , having the following properties: It is a concatenation of one or more words consisting of English letters. All letters in the first word are lowercase. For each of the subsequent words, the first letter is uppercase and rest of the letters are lowercase...

HackerRank ‘Caesar Cipher’ Solution


Short Problem Definition: Julius Caesar protected his confidential information from his enemies by encrypting it. Caesar rotated every alphabet in the string by a fixed number K. This made the string unreadable by the enemy. You are given a string S and the number K. Encrypt the string and print the encrypted string. Link Caesar Cipher Complexity: time complexity is O(?) space complexity is O(?)...

HackerRank ‘Breaking The Records’ Solution


Short Problem Definition: Maria plays college basketball and wants to go pro. Each season she maintains a record of her play. She tabulates the number of times she breaks her season record for most points and least points in a game. Points scored in the first game establish her record for the season, and she begins counting from there. Link Breaking The Records Complexity:...

HackerRank ‘Bon Appétit’ Solution


Short Problem Definition: Anna and Brian are sharing a meal at a restaurant and they agree to split the bill equally. Brian wants to order something that Anna is allergic to though, and they agree that Anna won’t pay for that item. Brian gets the check and calculates Anna’s portion. You must determine if his calculation is correct. Link Bon Appétit Complexity: time complexity is O(N) space...

HackerRank ‘Birthday Chocolate’ Solution


Short Problem Definition: The member states of the UN are planning to send 2 people to the moon. They want them to be from different countries. You will be given a list of pairs of astronaut ID’s. Each pair is made of astronauts from the same country. Determine how many pairs of astronauts from different countries they can choose from. Link Birthday Chocolate Complexity: time complexity is O(N)...

HackerRank ‘Bigger is Greater’ Solution


Short Problem Definition: Given a word w, rearrange the letters of w to construct another word in such a way that is lexicographically greater than w. In case of multiple possible answers, find the lexicographically smallest one among them. Link Bigger is Greater Complexity: time complexity is O(N) space complexity is O(N) Execution: This task challenges us to find the next...

HackerRank ‘Between Two Sets’ Solution


Short Problem Definition: You will be given two arrays of integers and asked to determine all integers that satisfy the following two conditions: The elements of the first array are all factors of the integer being considered The integer being considered is a factor of all elements of the second array Link Between Two Sets Complexity: time complexity is O(A* (N+M)) space complexity is O(1)...

HackerRank ‘Balanced Parentheses’ Solution


Short Problem Definition: Given a sequence consisting of parentheses, determine whether the expression is balanced. Link Balanced Parentheses Complexity: time complexity is O(N) space complexity is O(N) Execution: Equivalent to Codility Brackets. Solution: 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 38 39 40 def isValidPair(left...

HackerRank ‘Apple and Orange’ Solution


Short Problem Definition: Sam’s house has an apple tree and an orange tree that yield an abundance of fruit. In the diagram below, the red region denotes his house, where s is the start point, and i is the endpoint. The apple tree is to the left of his house, and the orange tree is to its right. You can assume the trees are located on a single point, where the apple tree is at point a, and the...