Tag: Code Corner

  • Word Reversal Code Challenge

    Word Reversal Code Challenge

    Here’s the scenario, you are given a string s that contains a sentence and your task is to write a word reversal function to reverse the order of all words that are longer than n characters. Example: s = The quick brown fox n = 4 Then the result should be “The kciuq nworb fox”…

  • Code Corner: Triangles

    Code Corner: Triangles

    For the last two weeks, I’ve had a bunch of interviews and code challenge tasks I was taking which took up a lot of my time. Add that to #DadLife and the result is two weeks with no content. The pressure is off for the moment so I’m picking it up again. So for today:…

  • Code Corner: Nested Squares

    Code Corner: Nested Squares

    Problem Draw three nested squares in html and css. My Solution Simple, you need three divs nested inside each other with a unique way of referencing them, the rest is done in CSS. I set the body to gray because reasons, there is really no need to do this. The first part is that all…

  • Code Corner: Counting Multiples

    Code Corner: Counting Multiples

    Problem We are given 3 numbers, a starting number A, an ending number B and an integer K, find the number of multiples of K there is between A and B inclusive. Source Example a = 6 b = 9 k = 2 Should return 2 My solution The ranges are irrelevant because this is…

  • Code Corner: Bracket Matching

    Code Corner: Bracket Matching

    Problem Given a string with brackets check to see if the brackets are properly nested. Source Example [] = return 1 () => 1 )( => 0 ({)} => 0 ” => 1 My Solution Classic stack problem. Didn’t need to brute first. The idea is you create a stack and loop through each character…

  • Code Corner: Max of 3

    Code Corner:  Max of 3

    Problem Given an n-length Array of integers ranging from -1000 to 1000 find the largest product of three numbers in A that you can get. Source Example [-3,2,6,4,8] => 192 My Solution There are three basic scenarios that can produce the largest product: The largest three positive numbers The largest positive number and the smallest…

  • Code Corner: 1-minute rule

    Code Corner: 1-minute rule

    So today’s task was so easy I’m going to do another one because I solved it way too fast. It’s really not that hard if you know some built-in data structures. Problem Source Given an n-length Array of numbers between -1,000,000 to 1,000,000, find the number of distinct values in the array. Example A =…

  • Code Corner: More Array Hijinks

    Code Corner: More Array Hijinks

    Problem We have another array operations question. This time we are given two inputs, a number n and a 2d array of operations. Each of the operations has 3 values, a start index, an end index and an increment value. Source: HackerRank The task is to implement each of those tasks on to a new…

  • Code Corner: Counting Operations

    Code Corner: Counting Operations

    Problem Codility MaxCounters We are given a number n and an array A of length m where each value in A is less than n+1 and greater than or equal to 1. We have to create a function that executes two operations using a new array of length n with initial values 0. The array…

  • Code Corner: Missing Number

    Code Corner: Missing Number

    Problem Source: Codility Given an array A of length n filled with integers find the smallest missing positive number. Example: [4,8,1,3,2] => 5 [1,2] =>3 Restrictions n ranges from 1 .. 100,000 Values of A range from -1,000,000 to 1,000,000 My Solution As usual, I decided to first take a brute force approach. As a…