hackerrank(9)
-
[HackerRank - Java] Day 4 - 1. Grid Challenge
Grid Challenge Given a square grid of characters in the range ascii[a-z], rearrange elements of each row alphabetically, ascending. Determine if the columns are also in ascending alphabetical order, top to bottom. Return YES if they are or NO if they are not. Example gird=[′abc′,′ade′,′efg′]gird = ['abc', 'ade', 'efg']gird=[′abc′,′ade′,′efg′] The grid is illustrated..
2023.01.29 -
[HackerRank - Java] Day 6 - 1. Simple Text Editor
Simple Text Editor Implement a simple text editor. The editor initially contains an empty string, SSS. Perform QQQ operations of the following 444 types: append(W) - Append string WWW to the end of SSS. delete(k) - Delete the last kkk characters of SSS. print(k) - Print the kthk^{th}kth character of SSS. undo() - Undo the last (not previously undone) operation of type 111 or 222, reverting SSS t..
2023.01.29 -
[HackerRank - Java] Day 4 - 2. Recursive Digit Sum
Recursive Digit Sum We define super digit of an integer xxx using the following rules: Given an integer, we need to find the super digit of the integer. If has only 111 digit, then its super digit is xxx. Otherwise, the super digit of xxx is equal to the super digit of the sum of the digits of xxx. For example, the super digit of 9875 will be calculated as: super_digit(9875) 9+8+7+5 = 29 super_d..
2023.01.28 -
[HackerRank - Java] Day 2 - 3. Counting Sort 1
Counting Sort 1 Comparison Sorting Quicksort usually has a running time of nnn x log(n)log(n)log(n), but is there an algorithm that can sort even faster? In general, this is not possible. Most sorting algorithms are comparison sorts, i.e. they sort a list just by comparing the elements to one another. A comparison sort algorithm cannot beat nnn x log(n)log(n)log(n) (worst-case) running time, sin..
2023.01.27 -
[HackerRank - Java] Day 2 - 2. Diagonal Difference
Diagonal Difference Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix is shown below: 1 2 3 4 5 6 9 8 9 The left-to-right diagonal 1+5+9=151 + 5 + 9 = 151+5+9=15. The right to left diagonal 3+5+9=173 + 5 + 9 = 173+5+9=17. Their absolute difference is ∣15−17∣=2|15 - 17| = 2∣15−17∣=2. Function description Complete the diagona..
2023.01.27 -
[HackerRank - Java] Day 2 - 1. Lonely Integer
Lonely Integer Given an array of integers, where all elements but one occur twice, find the unique element. Example a=[1,2,3,4,3,2,1]a = [1, 2, 3, 4, 3, 2, 1]a=[1,2,3,4,3,2,1] The unique element is 4. Function Description Complete the lonelyinteger function in the editor below. lonelyinteger has the following parameter(s): int a[n]: an array of integers Returns int: the element that occurs only ..
2023.01.27