Permutation of A String

Today we are going to talk about permutations of a string. I recently went through an interview where they ask me three questions that I had to complete in 30 minutes i left the permutation of a string for last.

I came up with an algorithm and drew out the pseudocode before. Loop through the string. Take the first letter of the word. At the letter to the new string and recurse through the strings.

`// If word is emptyif (word.length() == 0) {System.out.print(ans + " ");return;}`

This is how we print out the word when…

Contains Word

I recently just had an interview, unfortunately i didn’t get the job because I made a rookie mistake.

The challenge was given a string , return true or false if the array contains the word in the string. If it has one more letter than the string return false

First mistake was using a HashSet instead of a HashMap. I also use another string to compare the two words by ascii value. I know the new string might not come back in the order of the original array but if the ascii value should be equal to the same value.

`…`

ReArrange Min/Max

Arrays Min and Max

I have been going over Data Structures and Algorithms in Java on Educative.io. You guys should check it out if you get the chance. I ran into this problem with arrays. I love the solution so I am going to show you how to solve this problem.

Today we are going to talk about rearranging values in array min and max form.

In this solution, we first create an empty array whose size is equal to the size of the original array

`int pointerSmall = 0;     //PointerSmall => Start of arrint pointerLarge = arr.length …`

Implement A Queue with Two Stacks

First we create our two stacks. One stack is going to be used to push the data and the other stack is going to be used to pop of the stack.

`class MyQueue {    private Stack<Integer> s1 = new Stack<>();    private Stack<Integer> s2 = new Stack<>();`

Lets initialize the queue and push the data in stack one

`public MyQueue() {            }        /** Push element x to the back of queue. */    public void push(int x) {        s1.push(x);    }`

Lets pop off stack two to get that first element from stack one by pushing all of the elements in from stack…

Palindrome Number

How I solved Palindrome Number Problem.

A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam, racecar. We are doing this with numbers instead.

`Input: 121Output: trueInput: -121Output: falseExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.Input: 10Output: falseExplanation: Reads 01 from right to left. Therefore it is not a palindrome.`

First i check for any negatives. Negatives can not be a palindrome number.

`if(x < 0){            return false…`

Breaks in Coding

Why breaks are so important for engineering.

This week since I am on vacation, I am going to speak about the importance of breaks. After going hard for two months straight. I have decided to give myself a week off.

Mental Health

Breaks in coding for your mental health are important. Trying to look at a problem banging your head against the wall does not help you solve the problem. Look at the example of the the fly stuck in a room or in a car. It ends up doing more damage to itself or never finds the answer to the problem…

Merge Sort in Java

Today we are going to look into merge sort in Java.

I have been completing Leetcode’s explore page. They state that There are two approaches to implement the merge sort algorithm: top down or bottom up. Here, we will explain the top down approach as it can be implemented naturally using recursion.

LeetCode states The merge sort algorithm can be divided into three steps, like all divide-and-conquer algorithms:

• Divide the given unsorted list into several sublists. (Divide)
• Sort each of the sublists recursively. (Conquer)

Merge the sorted sublists to produce new sorted list. (Combine)

• In the first step, we divide…

Monotonic Array

What is a monotonic array?

An array is monotonic if it is either monotone increasing or monotone decreasing.

Example …

`Input: [1,2,2,3]Output: trueInput: [1,3,2]Output: falseInput: [1,2,4,5]Output: true`

As you can see it is only monotonic if the array is strictly increasing or strictly decreasing. How do we solve this ? Simple , we set two boolean values, to see if it is either decreasing or increasing.

`var isMonotonic = function(A) { let increasing = true  let decreasing = true`

Next we have to check if the element before the current element or the element next…

Minimum Depth of Binary Tree in JavaScript

Data Structures can be a bit challenging especially for someone who does not have a traditional CS Degree. However, anybody can get better at them with time and practice today I’m going to show you have to solve the minimum depth of a binary tree.

A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child. Finding the min depth of a binary tree is how deep a tree where we reach a leaf node. …

My First Tech interview

Hello To Whomever Is Reading This !

Today I am going to talk about my first tech interview experience. Out of respect to the company and its privacy I am not going to share their name. With that being said, lets call this company, Company A.

I received a phone call about an month ago from a recruiter, speaking about a possible interview with a tech company. …

Xavier Carty

Learning new things everyday and sharing them with them world. Software Engineering , Muay Thai , and Soccer are my passions.

Get the Medium app