top of page
Caută

Weighted Job Scheduling in JAVA

You receive a list of jobs that have three elements: start time, finish time and profit. You have to schedule the jobs with no...

Total number of non-decreasing numbers with n digits in JAVA

A non-decreasing number has every digit greater than or equal to the previous digit. Given the number of digits, find how many numbers...

Tiling Problem in JAVA

You can use a board that is 2 x n size. The tiles are of size 2 x 1. Count the number of ways to tile the board. Tiles can be placed...

Subset Sum Problem in JAVA

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with the sum equal to the given...

Shortest Common Supersequence in JAVA

Given two strings as input, the task is to find the length of the shortest string that has both strings as subsequences. Solution: 1. ...

Palindrome Partitioning in JAVA

Starting from a string, we determine it’s a palindrome partitioning by diving it into substrings, each being a palindrome. In our problem...

Mobile Numeric Keypad Problem in JAVA

We use a mobile numeric keyboard. You can only press buttons that are up, left, right or down to the current button. You are not allowed...

Minimum number of jumps to reach the end in JAVA

We start from an array of integers, where each number means how many steps can be made from that position. First, we are on index 0 of...

Minimum Initial Points to Reach Destination in JAVA

We have as an input a grid of cells with numbers. The numbers can be 0, positive or negative. To move across a cell, we must have...

Minimum Cost Polygon Triangulation in JAVA

You must find the minimum cost triangulation of a convex polygon. A triangulation is formed by drawing diagonals between nonadjacent...

Maximum sum rectangle in a 2D matrix in JAVA

Given a 2D array, find the maximum sum submatrix in it. Solution: 1. private static int maximumSumRectangle(int[][] matrix) { 2. ...

Maximum Sum Increasing Subsequence in JAVA

You are given an array of positive integers. You must write a program that will return the sum of the maximum sum subsequence of the...

Maximum Length Chain of Pairs in JAVA

You receive as input n pairs of numbers. In every pair, the first number is smaller than the second one. A chain of pairs (a, b), (c, d)...

Longest Palindromic Substring in JAVA

Starting from a string, we have to find the longest substring which is a palindrome. Solution: 1. static String...

Longest Palindromic Subsequence in JAVA

Given a sequence of letters, find the length of the longest palindromic subsequence in it. Solution: 1. public static void main(String[]...

Longest Bitonic Subsequence in JAVA

A Bitonic Subsequence is a part of a sequence that is formed first by increasing numbers, and after that by decreasing numbers. Write a...

bottom of page