본문 바로가기

전체 글11

Codility[Lesson 3] - Time Complexity(FrogJmp) A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must perform to reach its target. Write a function: class Solution { public int solution(int X, int Y, int D); } that, given three inte.. 2021. 8. 26.
[JAVA] Java에서 InputStream 변환 Byte Array ByteBuffer java로 파일전송을 하거나 파일을 다루게 되는 경우 Stream을 Byte로 바꿔서 다뤄줘야 하는 경우에 사용하게 된다. 1. Byte Array 로 변경하는 방법 InputStream is = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); byte[] targetArray = new byte[is.available()]; is.read(targetArray); InputStream is =new ByteArrayInputStream(newbyte[] { 0, 1, 2, 3, 4, 5, 6 }); // not really known ByteArrayOutputStream buffer =new ByteArrayOutputStream(); int nRead; by.. 2021. 8. 26.
Codility[Lesson 2] - Arrays(OddOccurrencesInArray) 보호되어 있는 글 입니다. 2021. 8. 8.
Codility[Lesson 2] - Arrays(CyclicRotation) An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is moved to the first place). The goal is to rotate array A K times; that is, each element .. 2021. 8. 8.