"Hej, Amigo. Her, tag denne interessante opgave:"
"Som sædvanligt vil den hemmelige agent give dig alle implementeringsdetaljerne."
20
Opgave
Java Collections, niveau, lektie
Unique substrings
Implement the lengthOfLongestUniqueSubstring method so that it returns the length
of the longest substring without repeated characters in the string passed as an argument.
For example, for "a123bcbcqwe", it should return 6. For "ttttwt", it should return 2.
10
Opgave
Java Collections, niveau, lektie
Bits were bits
While developing a complex encryption algorithm, there was a need to determine whether the binary representation of a number has
an even number of ones.
Implement the boolean isWeightEven(long number) method.
20
Opgave
Java Collections, niveau, lektie
Unequal exchange
Continuing the development of the algorithm, we could really use a method that can swap specified bits
in the binary representation of a long.
Implement a long swapBits(long number, int i, int j) method that swaps the bits with indices i and j in the binary
representation of number.
20
Opgave
Java Collections, niveau, lektie
Stairs
A boy runs up a flight of stairs consisting of n steps; in 1 bound, he can move up one, two or three steps.
Implement the numberOfPossibleAscents(int n) method, which should return the number of ways the boy can
ascend an entire flight of stairs consisting of n steps.
20
Opgave
Java Collections, niveau, lektie
Fill 'er up
While developing a new version of a popular graphics editor, it has become necessary to implement the ability
to fill an area of an image with a specified color.
20
Opgave
Java Collections, niveau, lektie
Interfaces will save us!
Amigo, help... I have no idea what to do. I carefully followed the specifications, which required me to create a system
for enabling an alarm. I created an alarm system (SecuritySystem) and power button (ElectricPowerSwitch),
and verified that it works in the Solution class's main method.
10
Opgave
Java Collections, niveau, lektie
ISP
The Worker interface contains too many methods that do too many different things. As a result, classes that want
to support only part of the functionality have to implement methods that they don't
actually need.
20
Opgave
Java Collections, niveau, lektie
Is a palindrome possible?
Implement the isPalindromePermutation(String s) method. It should return true if you can make a palindrome from all
the characters in string s. Otherwise, it should return false.
The passed string includes only ASCII characters.
Ignore the case of the letters.
20
Opgave
Java Collections, niveau, lektie
One change
Implement the isOneEditAway(String first, String second) method that returns true if it is possible
to edit/add/delete one character in one of the strings to get the other string.
The passed string includes only ASCII characters.
Ignore the case of the characters.
10
Opgave
Java Collections, niveau, lektie
isPowerOfThree
Fix the bug in the isPowerOfThree(int n) method. It should return true if n is an integer
power of the number 3. Otherwise, it should return false.
10
Opgave
Java Collections, niveau, lektie
Rollback
You must implement the rollback method in the Software class. It should make it possible to roll back the current software version
to the desired version. All versions after the one we roll back to must be removed. And don't forget
to change the currentVersion field.
20
Opgave
Java Collections, niveau, lektie
Maximum area
Implement the int maxSquare(int[][] matrix) method. IT returns the area of the largest square
of ones in the two-dimensional array called matrix.
The matrix array contains only zeros and ones.