All Questions
20 questions
4
votes
3
answers
426
views
Find the first missing positive integer in an array of integers
The problem is the one explained in Given an unsorted integer array, find the first missing positive integer
Given an unsorted integer array, find the first missing positive
integer.
For ...
3
votes
1
answer
3k
views
Circuit builder that calculates resistance/current/voltage
I am somewhat new to programming. I've written a program that takes user input accepting voltages and resistors, and calculating total resistance/current/voltage in the circuit. I am looking for ways ...
1
vote
1
answer
335
views
Rearrange an array in place such that the first and last halves are interleaved
Given an array of n elements in the following format { a1, a2, a3, a4,
….., an/2, b1, b2, b3, b4, …., bn/2 }. The task is shuffle the array
to {a1, b1, a2, b2, a3, b3, ……, an/2, bn/2 } without ...
2
votes
3
answers
315
views
Three Numbers in Java
Given three positive numbers A, B, and C. Find the number of positive
integers less than D that are divisible by either of A, B or C.
Input format
The 1st argument given is an Integer A. ...
1
vote
2
answers
631
views
Subset Sums in Java
Given an array of integers, print sums of all subsets in it. Output
should be printed in increasing order of sums.
Input :
arr[] = {2, 3}
Output:
0 2 3 5
Input :
...
1
vote
3
answers
6k
views
Sort all even numbers in ascending order and then sort all odd numbers in Descending order Java
Given an array of integers (both odd and even), the task is to sort
them in such a way that the first part of the array contains odd
numbers sorted in descending order, rest portion contains even ...
7
votes
5
answers
3k
views
Sort an array of 0s, 1s and 2s in Java
Write a program to sort an array of 0's,1's and 2's in ascending
order.
Input:
The first line contains an integer 'T' denoting the total number of
test cases. In each test cases, First line is number ...
2
votes
6
answers
1k
views
Alone in a Couple implementation in Java
In a party everyone is in couple except one. People who are in couple
have same numbers. Find out the person who is not in couple.
Input:
The first line contains an integer \$T\$ denoting ...
0
votes
1
answer
909
views
Reversing the vowels in a String
Given a string, reverse only the vowels present in it and print the
resulting string.
Input:
First line of the input file contains an integer T denoting the
number of test ...
2
votes
1
answer
184
views
Anagram checking implementation
Given two strings, check whether two given strings are anagram of each
other or not. An anagram of a string is another string that contains
same characters, only the order of characters can be ...
3
votes
2
answers
522
views
Non repeating character in Java
Given a string s consisting of lowercase Latin Letters, find the
first non repeating character in s.
Input:
The first line contains T denoting the number of testcases. Then
follows ...
1
vote
2
answers
966
views
Star Elements implementation in Java
Given an unsorted array. The task is to find all the star and super
star elements in the array. Star are those elements which are strictly
greater than all the elements on its right side. Super ...
2
votes
2
answers
521
views
Greater on the right side in Java
Given an array of integers, replace every element with the next
greatest element (greatest element on the right side) in the array.
Since there is no element next to the last element, replace it ...
0
votes
2
answers
3k
views
Count the number of occurences of X's within a range in Java
Given an integer X within the range of 0 to 9, and given two positive
integers as upper and lower bounds respectively, find the number of
times X occurs as a digit in an integer within the ...
1
vote
2
answers
183
views
Count total set bits
Im am solving Count total set bits:
Find the sum of all bits from numbers 1 to N.
Input:
The first line of input contains an integer T denoting the number of
test cases. The first line ...