✨ 문제 The K Weakes Rows in a Matrix You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.A row i is weaker than a row j if one of the following is true:The number of soldiers in row i is less than the number of soldier..
코딩테스트 준비
✨ 문제 Delete Greatest Value in Each RowYou are given an m x n matrix grid consisting of positive integers.Perform the following operation until grid becomes empty:Delete the element with the greatest value from each row. If multiple such elements exist, delete any of them. Add the maximum of deleted elements to the answer.Note that the number of columns decreases by one after each operation.Retur..
✨ 문제 Baseball GamesYou are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record.You are given a list of strings operations, where operations[i] is the ith operation you must apply to the record and is one of the following:An integer x.Record a new score of x.'+'Record a new score that is the sum of the previous two scores.'D'Reco..
✨ 문제 Final Prices With a Special Discount in a ShopYou are given an integer array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] . Otherwise, you will not receive any discount at all . Retur..
✨ 문제 Number of Recent CallsYou have a RecentCounter class which counts the number of recent requests within a certain time frame.Implement the RecentCounter class:RecentCounter() Initializes the counter with zero recent requests. int ping(int t) Adds a new request at time t, where t represents some time in milliseconds, and returns the number of requests that has happened in the past 3000 millis..
✨ 문제 Number of Students Unable to Eat LunchThe school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a stack. At each step:If the student at..
✨ 문제 Find Targer Indices After Sorting ArrayYou are given a 0-indexed integer array nums and a target element target.A target index is an index i such that nums[i] == target.Return a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order. https://leetcode.com/problem..
✨ 문제 Neither Minimum nor MaximumGiven an integer array nums containing distinct positive integers, find and return any number from the array that is neither the minimum nor the maximum value in the array, or -1 if there is no such number. Return the selected integer. https://leetcode.com/problems/neither-minimum-nor-maximum/description/ ✨ 최종코드class Solution { public int findNonMinOrMax(int..
✨ 문제 Decode the MessageYou are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows:Use the first appearance of all 26 lowercase English letters in key as the order of the substitution table.Align the substitution table with the regular English alphabet.Each letter in message is then substituted using the t..
✨ 문제 Shuffle StringYou are given a string s and an integer array indices of the same length.The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return the shuffled string. https://leetcode.com/problems/shuffle-string/description/ ✨ 최종코드class Solution { public String restoreString(String s, int[] indices) { char[] answe..