본문 바로가기
320x100
728x90

알고리즘15

LeetCode Valid Anagram https://leetcode.com/problems/valid-anagram/description/ Valid Anagram - LeetCode Can you solve this real interview question? Valid Anagram - Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using leetcode.com 이 문제는 애너그램에 관한 문제다. 애너그램이란 특정 문자를 재배치했을 때, 인풋으.. 2023. 7. 28.
프로그래머스,java]Level2 기능개발 순서가 바뀌면 안 되는 작업 진척률 progresses와 speeds를 반복문을 돌며 앞 인덱스가 다 되어야 배포를 하는 방식이다. 반복문을 돌면서 진척률이 100이 되었다면 100 인애들 다 앞에서부터 배포하고 100이 안됐다면 speeds만큼 더하면 된다. 👨🏻‍💻나의 풀이 import java.util.*; class Solution { public int[] solution(int[] progresses, int[] speeds) { ArrayList list = new ArrayList(); int index = 0; while (true) { int count = 0; if (progresses[index] >= 100) { for (int i = index; i < progresses.len.. 2022. 2. 19.
프로그래머스] 로또의 최고 순위와 최저 순위 문제 설명 : 로또 번호가 일부 훼손되어 알 수 없는 수가 0으로 표기되고, 내가 찍은 번호와 당첨 번호가 주어질 때, 알 수 없는 수가 다 맞을 경우, 다 맞추지 못할 경우에 대비해 최고, 최저 순위를 리턴하는 문제. 일단 이 문제를 보고 정렬이 되어있지 않다고 해서 정렬을 해야겠다고 생각했고, (빠른 탐색을 위해) 0의 갯수를 찾아놓고 맞춘 개수 + 0의 개수는 최대한 많이 맞출 수 있는 최고 순위일 것이다. 최저 순위는 단순히 맞춘 갯수만 카운트하면 된다. 👨🏻‍💻 나의 풀이 import java.util.*; class Solution { public int[] solution(int[] lottos, int[] win_nums) { Arrays.sort(lottos); Arrays.sort(wi.. 2022. 2. 18.
프로그래머스]두 개 뽑아서 더하기 문제 설명 : numbers 배열이 주어질 때, 2개를 뽑아서 더해서 나올 수 있는 모든 수를 오름차순으로 정렬. 나의 풀이 import java.util.*; class Solution { public int[] solution(int[] numbers) { int[] answer = {}; ArrayList list =new ArrayList(); for(int i=0 ; i 2022. 1. 31.
300x250
320x100