How to Remove First and Last Character in a String in Java
The challenge
The goal is to create a function that removes the first and last characters of a string. You don’t have to worry with strings with …
Read Article →In-depth guides, insights, and best practices for modern software engineering
The goal is to create a function that removes the first and last characters of a string. You don’t have to worry with strings with …
Read Article →There are N children standing in a line. Each child is assigned a rating value.
You are giving candies to these children subjected to …
Read Article →You have n candies, the i<sup>th</sup> candy is of type candies[i].
You want to distribute the candies equally between a …
Read Article →You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the i<sup>th</sup> …
Write a function which takes a number and returns the corresponding ASCII char for that value.
Example:
Ascii.getChar(65) // => …
Read Article →
Can you find the needle in the haystack?
Write a function findNeedle() that takes an array full of junk but containing one …
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row. Each glass …
Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < …
Replace all vowel to exclamation mark in the sentence. aeiouAEIOU is vowel.
replace("Hi!") === "H!!" …
Read Article →
You are given an array with positive numbers and a number N. You should find the N-th power of the element in the array with the index …
Read Article →Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes along the shortest path from the root node down to …
Read Article →You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at …
Read Article →Given a reference of a node in a connected undirected graph.
Return a deep copy (clone) of the graph. Effectively a graph copy.
Each …
Read Article →Ghost objects are instantiated without any arguments.
Ghost objects are given a random color attribute of white" or …
Read Article →Compare two version numbers version1 and version2.
If <em>version1</em> > <em>version2</em> …
Create a method take that accepts a list/array and a number n, and returns a list/array array of the first n elements from the …
Read Article →Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Write a function that returns the total surface area and volume of a box as an array: [area, volume]
We know that …
Read Article →Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an …
Read Article →There comes a time when you need to split out a subdirectory into it’s own git repo.
This is a very simple task if you don’t care about …
Read Article →Given a non-empty array of numbers, a, a1, a2, … , an-1, where 0 ≤ ai < 231.
Find the maximum result of ai XOR aj, where 0 ≤ i, j …
Read Article →Given a number, find its opposite.
Examples:
1: -1
14: -14
-34: 34
We return the number itself multiplied by a …
Read Article →You are given the length and width of a 4-sided polygon. The polygon can either be a rectangle or a square.
If it is a square, return …
We take in a String where the first place contains a number, write a function that takes in this String and returns an int containing …