반응형

00_coding_study 19

[leetcode] No 75. Sort Colors python3 solution

[Problem] Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively. You must solve this problem without using the library's sort function. 빨강색(0), 하얀색(1), 파란색(2)이 랜덤하게 섞여있는 배열을 빨..

00_coding_study 2023.04.02

[leetcode] No 28. Find the Index of the First Occurrence in a String (python3)

[Problem] Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. [Solution] It is quite simple! 1) First, check a length of 'haystack' is shorter than a length of 'needle'. If it is, return -1. 2) Second, before checking all characters between haystack and needle, I checked the last character and the first t..

00_coding_study 2023.02.26