2022년 2월 23일 수요일

Codility - 코딩테스트 기록용 4일차

 FrogJmp

Count minimal number of jumps from position X to Y.
int값 세개 , X, Y, D값을 입력받아
X의 위치에서 Y까지 D만큼씩 이동했을떄 몇번 이동해야하는지 구하는 문제
 - 내가 푼 코드
public static int solution(int X, int Y, int D) {
int result = ((Y - X) / D) ;
int cha = ((Y - X) % D);
if(cha > 0) {
result++;
}
if(X >= Y) {
result = 0;
}
return result;
}

- 다른사람이 푼 코드 
public int solution(int X, int Y, int D) {
        if(X == Y) return 0;
     return (Y-X)%D == 0? (Y-X)/D : (Y-X)/D + 1;
}
결국 똑같은거지? 

- Swift 버전

func solution(X:Int, Y:Int, D:Int) -> Int{

    var result = (Y-X)/D

    let cha = (Y-X)%D

    if cha > 0{

        result += 1

    }

    

    if X >= Y{

        result = 0

    }

    return result;

}

2022년 2월 3일 목요일

Codility - 코딩테스트 기록용 3일차

 OddOccurrencesInArray

-Find value that occurs in odd number of elements.

N개의 배열에서 짝을 이루지 않는 값을 찾아내기

프로그래머스에서 몇개 풀고왔는데 비슷한 문제가 나왔다

Map을 사용해서 getOrDefault함수를 사용했다

그리고 마지막엔 나머지값이 1인 값을 찾아내기!

public int solution(int[] A) { // write your code in Java SE 8 Map<Integer, Integer> map = new HashMap<>(); for(int i=0; i<A.length; i++){ map.put(A[i], map.getOrDefault(A[i], 0) + 1); } for(int key : map.keySet()){ if(map.get(key) % 2 == 1) {

                return key;

            }

} return -1; }

다른사람이 짠 코드도 비슷하다

하하 이번엔 비슷했다.

SWIFT버전

public func solution(_ A : inout [Int]) -> Int {
    // write your code in Swift 4.2.1 (Linux)
    var map = Dictionary<Int, Int>();

    A.forEach { index in
    map[index] = (map[index, default: 0]) + 1
    }
    
    var result = -1
    map.forEach { (key: Int, value: Int) in
        if(value % 2 == 1){
            result = key
        }
    
    }
    return result
}

2022년 1월 27일 목요일

Codility - 코딩테스트 기록용 2일차

CyclicRotation

 Rotate an array to the right by a given number of steps.

-배열을 주어진 숫자만큼 돌려서 원하는 값을 찾는다

-변경되어야 할 배열순사를 지켜야했음 

-내가 짠 코드

public static int[] solution(int[] A, int K) {

        // write your code in Java SE 8

        int[] result = new int[A.length];

        System.err.println("lenth = "+A.length);

        if(A.length == K){

            return A;

        }     

        

        for (int i = 0; i < A.length ; i++) {

        result[(i+K) % A.length] = A[i];

        System.err.println("i = "+i+" = "+result[i]);

        }

        for (int i = 0; i < result.length; i++) {

System.err.println("a["+i+"] = " +result[i]);

}

        return result;

    }

--다른사람이 짠 코드

class Solution {
    public int[] solution(int[] A, int K) {
        // write your code in Java SE 8
        int len = A.length;
        if(len == 0 || K % len == 0) return A;
        int [] ans = new int [len];

        K = K % len;

        for (int i=0; i< len; i++){
            ans[(i+K) % len] = A[i];
        }
        return ans;
    }
}
역시 개깔끔...나는 멀었나보다
-swift 코드 
public func solution(_ A : inout [Int], _ K : Int) -> [Int] {
    // write your code in Swift 4.2.1 (Linux)
    
    if A.count == K{
        return A
    }
    var result = A
    for i in 0..<A.count{
        let num = (i+K)%A.count
        result[num] = A[i]
    }
    return result
}

2022년 1월 25일 화요일

Codility - 코딩테스트 기록용 1일차

 BinaryGap

Find longest sequence of zeros in binary representation of an integer.

이진법으로 변환 후 1과 1사이의 0의 값을 추출한다.

내가 푼 방법 

public static int solution(int N) {

        // write your code in Java SE 8

String binary = Integer.toBinaryString(N);

List<Integer> aArray = new ArrayList();

int result = 0;

for (int i = 0; i < binary.length(); i++) {

if(binary.charAt(i) == '1') {

aArray.add(i);

}

}

int max = 0;

int val = 0;

for (int i = 0; i < aArray.size() -1; i++) {

if(i == 0) {

max = binary.substring(aArray.get(i), aArray.get(i+1)).length() -1;

}else {

val = binary.substring(aArray.get(i), aArray.get(i+1)).length() -1;

}

if(i > 0) {

max = Integer.max(max, val);

}

}

if(aArray.size() < 2) {

max = 0;

}

return max;

    }


-> 다른 사람이 푼 코드 

class Solution {
    public int solution(int N) {
        // write your code in Java SE 8

        String binaryNum = Integer.toBinaryString(N);
        int temp = 0;
        int maxLen = temp;

        for(int i=1; i< binaryNum.length(); i++){
            if(binaryNum.charAt(i) == '0') temp++;
            else{
                maxLen = Math.max(maxLen, temp);
                temp = 0; 
            }
        }
        return maxLen;
    }
}
개깔끔.. 왜 저생각을 못했지.. 분발하자!

SWIFT 버전

public func solution(_ N: Int) ->Int{

    var result = 0

    let binary = String(N, radix: 2, uppercase: true)

    var tmp = 0;

    for char in binary {

        if char == "0"{

            tmp += 1

        }else{

            result = max(result, tmp)

            tmp = 0

        }

    }

    return result

}


2018년 10월 4일 목요일

Privacy Policy

Privacy Policy

realslow built the MyBookMark app as a Free app. This SERVICE is provided by realslow at no cost and is intended for use as is.
This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.
If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.
The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at MyBookMark unless otherwise defined in this Privacy Policy.
Information Collection and Use
For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I request will be retained on your device and is not collected by me in any way.
The app does use third party services that may collect information used to identify you.
Link to privacy policy of third party service providers used by the app
Log Data
I want to inform you that whenever you use my Service, in a case of an error in the app I collect data and information (through third party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing my Service, the time and date of your use of the Service, and other statistics.
Cookies
Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.
This Service does not use these “cookies” explicitly. However, the app may use third party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this Service.
Service Providers
I may employ third-party companies and individuals due to the following reasons:
  • To facilitate our Service;
  • To provide the Service on our behalf;
  • To perform Service-related services; or
  • To assist us in analyzing how our Service is used.
I want to inform users of this Service that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.
Security
I value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and I cannot guarantee its absolute security.
Links to Other Sites
This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by me. Therefore, I strongly advise you to review the Privacy Policy of these websites. I have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.
Children’s Privacy
These Services do not address anyone under the age of 13. I do not knowingly collect personally identifiable information from children under 13. In the case I discover that a child under 13 has provided me with personal information, I immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact me so that I will be able to do necessary actions.
Changes to This Privacy Policy
I may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. I will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately after they are posted on this page.
Contact Us
If you have any questions or suggestions about my Privacy Policy, do not hesitate to contact me.
This privacy policy page was created at privacypolicytemplate.net and modified/generated by App Privacy Policy Generator

2016년 10월 25일 화요일

맥북에서 Android Jni사용

처음으로 Android Jni를 사용하는데
헤더 파일이 생성이 안된다.....

왜지??

프로젝트 bin/classes 에서

javah -classpath ${android_home}/android.jar com.ex.hellojni


Could not find class................

윈도우에서 해보니 정상동작...뭐지??

맥에서는 경로를 못찾나보다;;

구글링 구글링...

세미콜론과 점을 찍으란다
javah -classpath ${android_home}/android.jar;. com.ex.hellojni

역시 실패

다시 구글링...
콜론과 점을 찍으란다
javah -classpath ${android_home}/android.jar:. com.ex.hellojni

오...성공!! ㅋㅋㅋ

참고로 ndk-bulider를 실행하기 위해선 .bash_profile에 NDK_HOME이 등록되어있어야한다.


오늘도 배웠다!!

참조 사이트

2016년 3월 17일 목요일

OC4J war file배포하기

1. oc4j instance 생성

$oracle_home/bin/createinstance -instanceName oc4japp01

2. war file 복사

아래 경로로 war file 복사
$oracle_home/j2ee/oc4japp01/application/

3. Application.xml 파일수정

$oracle_home/j2ee/oc4japp01/config/application.xml

...
<web-module id ="testWeb" path="../../oc4japp01/applications/test.war"/>
...

4. default-web-site.xml 파일수정

$oracle_home/j2ee/oc4japp01/config/default-web-site.xml

...
<default-web-app application="default" name="defaultWebApp" root="/j2ee"/>
<web-app application="default" name="testWeb" load-on-startup="true" root="/test"/>
...

5. opmn stop & opmn start

명령어
$oracle_home/opmn/bin opmnctl stopall
$oracle_home/opmn/bin opmnctl startall


--------------------------------------------------------------
포트 번호는 $oracle_home/Apache/Apache/conf/httpd.conf 안에 listen 과 port를 참고

windows 기준으로 작성됨