Leetcode
-
숫자로 된 배열이 주어졌을 때, 1이 연속되게 나오는 횟수가 제일 큰 것을 구해야 한다. 먼저 처음 들었던 생각은 '1 뒤에 1이 올 때와 1 뒤에 0이 올 때로 나눠서 풀어야하나..?' 였다. 그래서 시도했던 로직은 제일 마지막 인덱스와 나머지를 구분한 뒤 케이스를 나눠주는 것이었다. index 1 뒤에 1이 올 때, 1 뒤에 0이 올 때 index == nums.length - 1 일 때 -> 1일 때, 0일 때 class Solution { public int findMaxConsecutiveOnes(int[] nums) { int max = 0; int count = 0; for(int i = 0; i < nums.length; i++) { if(i <..
[리트코드] Introduction - Max Consecutive Ones숫자로 된 배열이 주어졌을 때, 1이 연속되게 나오는 횟수가 제일 큰 것을 구해야 한다. 먼저 처음 들었던 생각은 '1 뒤에 1이 올 때와 1 뒤에 0이 올 때로 나눠서 풀어야하나..?' 였다. 그래서 시도했던 로직은 제일 마지막 인덱스와 나머지를 구분한 뒤 케이스를 나눠주는 것이었다. index 1 뒤에 1이 올 때, 1 뒤에 0이 올 때 index == nums.length - 1 일 때 -> 1일 때, 0일 때 class Solution { public int findMaxConsecutiveOnes(int[] nums) { int max = 0; int count = 0; for(int i = 0; i < nums.length; i++) { if(i <..
2023.11.28 -
리트코드 Explore -> Learn 섹션에 접속하기 리트코드의 explore 접속 URL https://leetcode.com/explore/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com Learn 섹션 푸는 순서
[리트코드] 처음부터 공부하는 방법리트코드 Explore -> Learn 섹션에 접속하기 리트코드의 explore 접속 URL https://leetcode.com/explore/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com Learn 섹션 푸는 순서
2023.11.28