[Lucky Algorithm] Equalize the Array (72/77)
Equalize the Array (Hacker Rank) Karl has an array of integers. He wants to reduce the array until all remaining elements are equal. Determine the fewest num...
Equalize the Array (Hacker Rank) Karl has an array of integers. He wants to reduce the array until all remaining elements are equal. Determine the fewest num...
Encryption (Hacker Rank) An English text needs to be encrypted using the following encryption scheme. First, the spaces are removed from the text. Let be th...
Greedy Florist (Hacker Rank)
Angry Professor (Hacker Rank) A Discrete Mathematics professor has a class of students. Frustrated with their lack of discipline, he decides to cancel class ...
Sherlock and Array (Hacker Rank) Watson gives Sherlock an array of integers. His challenge is to find an element of the array such that the sum of all elemen...
Permuting Two Arrays (Hacker Rank)
The Great XOR (Hacker Rank)
Army Game (Hacker Rank) Luke is daydreaming in Math class. He has a sheet of graph paper with rows and columns, and he imagines that there is an army base i...
Utopian Tree (Hacker Rank) The Utopian Tree goes through 2 cycles of growth every year. Each spring, it doubles in height. Each summer, its height increases ...
Maximizing XOR (Hacker Rank) Given two integers, and , find the maximal value of xor , written , where and satisfy the following condition:
Max Min (Hacker Rank) You will be given a list of integers, , and a single integer . You must create an array of length from elements of such that its unfa...
Cavity Map (Hacker Rank) You are given a square map as a matrix of integer strings. Each cell of the map has a value denoting its depth. We will call a cell ...
Designer PDF Viewer (Hacker Rank) When you select a contiguous block of text in a PDF viewer, the selection is highlighted with a blue rectangle. In a new ki...
Day 26: Nested Logic (Hacker Rank) Objective Today’s challenge puts your understanding of nested conditional statements to the test. You already have the kno...
Intro to Tutorial Challenges (Hacker Rank) This is a simple challenge to get things started. Given a sorted array () and a number (), can you print the index...
Alternating Characters (Hacker Rank) You are given a string containing characters and only, your task is to change it into a string such that every two con...
Maximum Perimeter Triangle (Hacker Rank) Given sticks of lengths , use of the sticks to construct a non-degenerate triangle with the maximum possible perim...
Lonely Integer (Hacker Rank) Consider an array of integers, , where all but one of the integers occur in pairs. In other words, every element in occurs exa...
Marc’s Cakewalk (Hacker Rank) Marc loves cupcakes, but he also likes to stay fit. He eats cupcakes in one sitting, and each cupcake has a calorie count, . ...
Tree: Postorder Traversal (Hacker Rank) Complete the postOrder function in your editor below, which has 1 parameter: a pointer to the root of a binary tree. ...
Correctness and the Loop Invariant (Hacker Rank) In the previous challenge, you wrote code to perform an Insertion Sort on an unsorted array. But how would y...
Ice Cream Parlor (Hacker Rank) Each time Sunny and Johnny take a trip to the Ice Cream Parlor, they pool together dollars for ice cream. On any given day, t...
Minimum Absolute Difference in an Array (Hacker Rank) Consider an array of integers, . We define the absolute difference between two elements, and (where ),...
Climbing the Leaderboard (Hacker Rank) Alice is playing an arcade game and wants to climb to the top of the leaderboard. Can you help her track her ranking a...
Picking Numbers (Hacker Rank) Given an array of integers, find and print the maximum number of integers you can select from the array such that the absolute ...
Jim and the Orders (Hacker Rank) Jim’s Burgers has hungry burger fans waiting in line. Each unique order, , is placed by a customer at time , and the order ...
Missing Numbers (Hacker Rank) Numeros, the Artist, had two lists and , such that was a permutation of . Numeros was very proud of these lists. Unfortunatel...
[Lesson10] Prime and composite numbers Flags : Find the maximum number of flags that can be set on mountain peaks.
[Lesson10] Prime and composite numbers CountFactors
[Lesson10] Prime and composite numbers MinPerimeterRectangle
[Lesson9] Maximum slice problem MaxSliceSum
[Lesson9] Maximum slice problem MaxProfit
[Lesson9] Maximum slice problem MaxDoubleSliceSum
[Lesson8] Leader EquiLeader
[Lesson8] Leader Dominator
[Lesson7] Stacks and Queues Fish Java Solution ``` import java.util.*;
[Lesson7] Stacks and Queues Fish
[Lesson7] Stacks and Queues Nesting Java Solution
[Lesson7] Stacks and Queues Brackets Java Solution
[Lesson7] Stacks and Queues StoneWall : Cover “Manhattan skyline” using the minimum number of rectangles Java Solution Link : https://codility.com/demo/res...
[Lesson6] Sorting MaxProductOfThree : Maximize A[P] * A[Q] * A[R] for any triplet (P, Q, R). Java Solution
[Lesson6] Sorting Triangle : Determine whether a triangle can be built from a given set of edges. Java Solution
[Lesson6] Sorting Distinct : Compute number of distinct values in an array. Java Solution ``` import java.util.*;
[Lesson5] Prefix Sums GenomicRangeQuery : Find the minimal nucleotide from a range of sequence DNA. Java Solution
[Lesson5] Prefix Sums MinAvgTwoSlice : Find the minimal average of any slice containing at least two elements. Java Solution Task Score : 80 Correctness : ...
[Lesson5] Prefix Sums PassingCars : Count the number of passing cars on the road. Java Solution Task Score : 90 Correctness : 100 Performance : 80 class S...
[Lesson4] Counting Elements MissingInteger : Find the smallest positive integer that does not occur in a given sequence.
[Lesson4] Counting Elements FrogRiverOne : Find the earliest time when a frog can jump to the other side of a river.
[Lesson4] Counting Elements PermCheck : Check whether array A is a permutation.
[Lesson3] Time Complexity FrogJmp : Count minimal number of jumps from position X to Y.
[Lesson3] Time Complexity PermMissingElem : Find the missing element in a given permutation.
[Lesson3] Time Complexity TapeEquilibrium : Minimize the value |(A[0] + … + A[P-1]) - (A[P] + … + A[N-1])|.
[Lesson5] Prefix Sums CountDiv : Compute number of integers divisible by k in range [a..b].
[Lesson4] Counting Elements MaxCounters : Calculate the values of counters after applying all alternating operations: increase counter by 1; set value of all...
[Lesson2] Arrays CyclicRotation : Rotate an array to the right by a given number of steps. Java Solution
[Lesson2] Array OddOccurrencesInArray : Find value that occurs in odd number of elements.
[Lesson1] Iterations BinaryGap : Find longest sequence of zeros in binary representation of an integer.
Fraudulent Activity Notifications (Hacker Rank) HackerLand National Bank has a simple policy for warning clients about possible fraudulent account activity. ...
Find the Median (Hacker Rank) Given a list of numbers, can you find the median?
Closest Number (Hacker Rank) Sorting is often useful as the first step in many different tasks. The most common task is to make finding things easier, but th...
The Full Counting Sort (Hacker Rank) In this challenge you need to print the data that accompanies each integer in a list. In addition, if two strings have t...
Counting Sort 2 (Hacker Rank) Often, when a list is sorted, the elements being sorted are just keys to other values. For example, if you are sorting files by...
Counting Sort 1 (Hacker Rank) Comparison Sorting Quicksort usually has a running time of , but is there an algorithm that can sort even faster? In general, t...
Running Time of Algorithms (Hacker Rank) In the previous challenges you created an Insertion Sort algorithm. It is a simple sorting algorithm that works well...
Insertion Sort - Part 2 (Hacker Rank) In Insertion Sort Part 1, you sorted one element into an array. Using the same approach repeatedly, can you sort an ent...
Insertion Sort - Part 1 (Hacker Rank) Sorting One common task for computers is to sort data. For example, people might want to see all their files on a compu...
Quicksort 1 - Partition (Hacker Rank) The previous challenges covered Insertion Sort, which is a simple and intuitive sorting algorithm with an average case ...
Weighted Uniform Strings (Hacker Rank) A weighted string is a string of lowercase English letters where each letter has a weight in the inclusive range from ...
The Power Sum (Hacker Rank) Find the number of ways that a given integer, , can be expressed as the sum of the power of unique, natural numbers.
Sherlock and the Valid String (Hacker Rank) Sherlock considers a string, , to be valid if either of the following conditions are satisfied:
Game of Stones (Hacker Rank) Two players (numbered and ) are playing a game with stones. Player always plays first, and the two players move in alternatin...
Pangrams (Hacker Rank) Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence “The quick brown fox...
HackerRank in a String! (Hacker Rank) We say that a string, , contains the word hackerrank if a subsequence of the characters in spell the word hackerrank. ...
Mars Exploration (Hacker Rank) Letters in some of the SOS messages are altered by cosmic radiation during transmission. Given the signal received by Earth as...
CamelCase (Hacker Rank) Alice wrote a sequence of words in CamelCase as a string of letters, , having the following properties:
Super Reduced String (Hacker Rank) Steve has a string, , consisting of lowercase English alphabetic letters. In one operation, he can delete any pair of adj...
Find Digits (Hacker Rank) Given an integer, , traverse its digits (1,2,…,n) and determine how many digits evenly divide (i.e.: count the number of times di...
The Hurdle Race (Hacker Rank) Dan is playing a video game in which his character competes in a hurdle race by jumping over hurdles with heights . He can ini...
Cats and a Mouse (Hacker Rank) Two cats named and are standing at integral points on the x-axis. Cat is standing at point and cat is standing at point ....
Electronics Shop (Hacker Rank) Monica wants to buy exactly one keyboard and one USB drive from her favorite electronics store. The store sells different bra...
Counting Valleys (Hacker Rank) Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his l...
Drawing Book (Hacker Rank) Brie’s Drawing teacher asks her class to open their -page book to page number . Brie can either start turning pages from the front...
Day of the Programmer (Hacker Rank) Marie invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of the Programmer (the da...
Sock Merchant (Hacker Rank) John’s clothing store has a pile of loose socks where each sock is labeled with an integer, , denoting its color. He wants to s...
Bon Appétit (Hacker Rank) Anna and Brian order items at a restaurant, but Anna declines to eat any of the item (where ) due to an allergy. When the check c...
Migratory Birds (Hacker Rank) A flock of birds is flying across the continent. Each bird has a type, and the different types are designated by the ID number...
Extra Long Factorials (Hacker Rank) You are given an integer . Print the factorial of this number.
Divisible Sum Pairs (Hacker Rank) You are given an array of integers, , and a positive integer, . Find and print the number of pairs where and + is divis...
Birthday Chocolate (Hacker Rank) Lily has a chocolate bar consisting of a row of squares where each square has an integer written on it. She wants to share ...
Breaking the Records (Hacker Rank) Maria plays games of college basketball in a season. Because she wants to go pro, she tracks her points scored per game s...
Between Two Sets (Hacker Rank) Consider two sets of positive integers, and . We say that a positive integer, , is between sets and if the following condit...
Kangaroo (Hacker Rank) There are two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo s...
Apple and Orange (Hacker Rank)
Grading Students (Hacker Rank) HackerLand University has the following grading policy:
Staircase (Hacker Rank) Given a time in -hour AM/PM format, convert it to military (-hour) time.
Birthday Cake Candles (Hacker Rank) Colleen is turning years old! Therefore, she has candles of various heights on her cake, and candle has height . Becau...
Mini-Max Sum (Hacker Rank) Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integ...
Staircase (Hacker Rank) Consider a staircase of size : # ## ### #### Observe that its base and height are both equal to , and the image is dr...
Plus Minus (Hacker Rank) Given an array of integers, calculate which fraction of its elements are positive, which fraction of its elements are negative, and ...
Diagonal Difference (Hacker Rank)
Compare the Triplets (Hacker Rank)
Halloween Sale (Hacker Rank) You wish to buy video games from the famous online video game store Mist.
Lucky 77 Algorithm Intro (Hacker Rank)
7장 딥러닝을 시작합니다 - 패션 럭키백을 판매합니다!
6장 - 비지도 학습 - 비슷한 과일끼리 모으자!
5장. 트리 알고리즘 - 화이트 와인을 찾아라!
4장. 다양한 분류 알고리즘 : 럭키백의 확률을 계산하라!
3장. 회귀 알고리즘과 모델 규제 : 농어의 무게를 예측하라!
2장. 데이터 다루기 : 수상한 생선을 조심하라!
1장. 나의 첫 머신러닝 : 이 생선의 이름은 무엇인가요?
디디디 원해!