Adobe Interview Question for MTSs


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

package com.home.careercup;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/*
50050055555555555510 base 10 =
11011110010001000101001101001111111110001100100100011100011 base 2
 */
public class NumberStreamModulo {
    public static void main(String[] args) {
        String stream = "11011110010001000101001101001111111110001100100100011100011";
        List<Character> list = stream.chars().mapToObj(x -> Character.valueOf((char) x)).collect(Collectors.toList());
        isDiv5(list.stream());
    }

    static void isDiv5(Stream<Character> s) {
        final int[] res = new int[]{0};
        final StringBuilder sb = new StringBuilder();
        s.forEach(d -> {
            sb.append(d);
            int bv = Character.valueOf(d) - Character.valueOf('0');
            res[0] = res[0] * 2 + bv;
            res[0] = res[0] % 5;
            System.out.printf("%s is %s divisible by 5%n", sb.toString(), res[0] == 0 ? "" : "NOT");

        });
    }
}

- Makarand September 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    string n;
    while(cin>>n)
    {
        int a;
        long  s=bitset<128>(n).to_ulong();
        if(s%5==0)
        {
            cout<<"true"<<endl;
        }
        else
        {
            cout<<"false"<<endl;
        }
        //cin>>a;
        
    }
	//code
	return 0;
}

- Shubhra Singh September 17, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

public static void main(String args[]) throws Exception {
		int K = 5;
		System.out.println(isBinaryDivisible(Long.toBinaryString(655515), K));
	}

	private static boolean isBinaryDivisible(String binaryString, int K) {
		char c[] = new StringBuilder(binaryString).reverse().toString().toCharArray();
		int rem = 0;
		for (int i = 0; i < c.length; i++) {
			rem = ((((int) Math.pow(2, i) * Integer.parseInt("" + c[i])) % K) + rem) % K;
		}
		return rem == 0;
	}

- koustav.adorable September 04, 2017 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More