zoukankan      html  css  js  c++  java
  • codility

    // you can also use imports, for example:
    // import java.util.*;
    
    // you can write to stdout for debugging purposes, e.g.
    // System.out.println("this is a debug message");
    
    class Solution {
        public int solution(int N) {
            // write your code in Java SE 8
            int tempMod=0;
            int length=0;
            int posOne=-1;
            int step=0;
             while(N>0){
                 tempMod=(N%2);
                 if(tempMod==1){
                     
                     if(posOne>=0){
                         length=(length < (step-posOne-1))?(step-posOne-1):length;
                         }
                     posOne=step;
                     }
                 
                 step++;
                 N=(N/2);
                 }
            return length;
        }
    }
    public int solution(int[] A) {
            // write your code in Java SE 8
            int i=0;
            int result=0;
            while(i<A.length){
                
                result=(result^A[i]);
                i++;
                }
            return result;
        }
    // you can also use imports, for example:
    // import java.util.*;
    
    // you can write to stdout for debugging purposes, e.g.
    // System.out.println("this is a debug message");
    
    class Solution {
        public int[] solution(int[] A, int K) {
            // write your code in Java SE 8
            int[] newA = new int[A.length];
            int i=0;
            while(i<A.length){
                newA[(i+K)%(A.length)]=A[i];
                i++;
                }
                
                return newA;
        }
    }
    MySQL限时解答,24小时内友哥专业解答
    http://www.yougemysqldba.com
    如有进一步需要请联系微信onesoft007
    微博账号@友哥一指
  • 相关阅读:
    bzoj4864 [BeiJing 2017 Wc]神秘物质
    HNOI2011 括号修复
    bzoj2402 陶陶的难题II
    ZJOI2008 树的统计
    USACO09JAN 安全出行Safe Travel
    HAOI2015 树上操作
    hdu5126 stars
    BOI2007 Mokia 摩基亚
    SDOI2011 拦截导弹
    国家集训队 排队
  • 原文地址:https://www.cnblogs.com/youge-OneSQL/p/6413316.html
Copyright © 2011-2022 走看看