전체 글
[LeetCode] Max Consecutive Ones
0과 1로 이루어진 nums 배열에서 연속된 1이 가장 많이 이어졌을때 수를 반환하시오 class Solution { public int findMaxConsecutiveOnes(int[] nums) { /* 이진 배열인 nums가 주어졌을때, 연속된 1의 최대수를 반환하시오. 1 = maximum) maximum = temp; } return maximum; } } Runtime: 1 ms, faster than 100.00% of Java online submissions for Max Consecutive Ones. Memory Usage: 40.2 MB, less than 76.94% of Java online submissions for Max Consecutive Ones.
[LeetCode] Minimum Number of Operations to Move All Balls to Each Box
You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the ith box is empty, and '1' if it contains one ball. In one operation, you can move one ball from a box to an adjacent box. Box i is adjacent to box j if abs(i - j) == 1. Note that after doing so, there may be more than one ball in some boxes. Return an array answer of size n, where answer[i] is the min..
[LeetCode] Jewels and Stones
You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters are case sensitive, so "a" is considered a different type of stone from "A". Example 1: Input: jewels = "aA", stones = "aAAbbbb" Output: 3 Example ..
[LeetCode] Kids With the Greatest Number of Candies
여분의 사탕으로 사탕을 가장 많이 가진 아이와 같은 수의 사탕을 만들 수 있는 경우의 수를 구하라는 문제 Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has. For each kid check if there is a way to distribute extraCandies among the kids such that he or she can have the greatest number of candies among them. Notice that multiple kids can have the greatest number of cand..
[LeetCode] Number of Good Pairs
Given an array of integers nums. A pair (i,j) is called good if nums[i] == nums[j] and i
[LeetCode] Kids With the Greatest Number of Candies
import java.util.*; class Solution { public List kidsWithCandies(int[] candies, int extraCandies) { int max = candies[0]; for (int i = 0; i max){ max = candies[i]; } } ArrayList result = new ArrayList(candies.length); for (int i = 0; i = max) { result.add(true); } else { result.add(false); } } retur..