How to Compare Version Numbers in Java
The challenge
Compare two version numbers version1 and version2.
If <em>version1</em> > <em>version2</em> …
345 articles about java development, tools, and best practices
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 →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 …
Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If …
Given a linked list, rotate the list to the right by k places, where k is non-negative.
Example 1:
Input: 1->2->3->4->5->NULL, k = 2 …Read Article →
You are given the root node of a binary search tree (BST) and a value to insert into the tree. Return the root node of the BST after the …
Every non-negative integer N has a binary representation. For example, 5 can be represented as "101" in binary, 11 as …
You have a RecentCounter class which counts the number of recent requests within a certain time frame.
Implement the RecentCounter …
Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0.
For …
Read Article →Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where …
Our football team finished the championship. The result of each match look like “x:y”. Results of all matches are recorded …
Read Article →a ,b ,c, return the largest number obtained after inserting the following operators and brackets: +, *, ()Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep …
Read Article →You are driving a vehicle that has capacity empty seats initially available for passengers. The vehicle only drives east (ie. it cannot …
Write a function called repeat_str which repeats the given string src exactly count times.
repeatStr(6, "I") // "IIIIII" …
Read Article →
Given an array of integers your solution should find the smallest integer.
For example:
[34, 15, 88, 2] your solution will return …Given a number n, return the number of positive odd numbers below n, EASY!
oddCount(7) //=> 3, i.e [1, 3, 5]
oddCount(15) //=> 7, …
Read Article →
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word (last word means …