본문 바로가기

파이썬87

CodeSignal [33/60] stringsRearrangement Problem Given an array of equal-length strings, you'd like to know if it's possible to rearrange the order of the elements in such a way that each consecutive pair of strings differ by exactly one character. Return true if it's possible, and false if not. Note: You're only rearranging the order of the strings, not the order of the letters within the strings! Example For inputArray = ["aba", "bbb.. 2020. 5. 23.
LeetCode 283. Move Zeroes Problem: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] -Summary- Used two-pointer using two loops. 1. set 1 pointer of for loop for the zero-value index in the nums list. 2. If zero index found, then we loop starting from the next index then find the number th.. 2020. 5. 22.
CodeSignal [26/60] evenDigitsOnly 문제: Check if all digits of the given integer are even. Examples: For n = 248622, the output should be evenDigitsOnly(n) = true; For n = 642386, the output should be evenDigitsOnly(n) = false. -문제 해결 정리- 1. 받는 input 'n' 인자를 string 으로 바꿔서 iterable 할수 있게 만들어 준다. 2. String 으로 바뀌어진 n 인자를 for loop 을 써서 2로 나누어 even 인지 odd 인지 확인해 준다. 3. 만약에 한 숫자라도 even 이 아닌 케이스 발견시, 바로 False 값으로 return. 모든 숫자가 even 일 경우.. 2020. 5. 17.