Nitin Agrawal
Contact -
  • Home
  • Interviews
    • InterviewFacts
    • Resume Thoughts
    • Companies >
      • InvestmentBanks >
        • ECS
        • Bank Of America
        • WesternUnion
        • WellsFargo
      • ProductBasedCompanies >
        • CA Technologies
        • Model N India
        • Verizon Media
        • Oracle & GoJek
        • IVY Computec
        • Samsung
        • ClearWaterAnalytics
        • ADP
        • ServiceNow
        • Pubmatic
        • Expedia
        • Amphora
        • CDK Global
        • Delphix
        • Fractal Enterprises LLP
        • CDK Global
        • Tide-Banking
        • Epic
      • ServiceBasedCompanies >
        • ASG World Wide Pvt Ltd
        • Paraxel International & Pramati Technologies Pvt Ltd
        • MitraTech
        • Intelizest Coding Round
        • ZeMoSo
    • Interviews Theory
  • Programming Languages
    • Java Script >
      • Tutorials
      • Code Snippets
    • Reactive Programming >
      • Code Snippets
    • R
    • DataStructures >
      • LeetCode Problems
      • AnagramsSet
    • Core Java >
      • Codility
      • Java14
      • Threading >
        • ThreadsOrder
        • ProducerConsumer
        • Finalizer
        • RaceCondition
        • Executors
      • Important Points
      • Immutability
      • Dictionary
      • Sample Code Part 1 >
        • PatternLength
        • Serialization >
          • Kryo2
          • JAXB/XSD
          • XStream
        • MongoDB
        • New methods in Collections
        • MethodReferences
        • Complex Objects Comparator >
          • Performance
        • NIO >
          • NIO 2nd Sample
        • Date Converter
        • Minimum cost path
        • Find File
      • URL Validator
    • Julia
    • Python >
      • Decorators
      • String Formatting
      • Generators_Threads
      • JustLikeThat
    • Go >
      • Tutorial
      • CodeSnippet
      • Go Routine_Channel
      • Suggestions
    • Methodologies & Design Patterns >
      • Design Principles
      • Design Patterns >
        • Decorator
        • Proxy
        • Lazy Initialization
        • CombinatorPattern
        • RequestChaining
        • Singleton >
          • Singletons
  • Frameworks
    • AngularJS
    • Apache Velocity
    • Spring >
      • Spring Boot >
        • Issues
      • Quick View
    • Rest WebServices >
      • Interviews
      • Swagger
    • Cloudera BigData >
      • Ques_Ans
      • Hive
      • Apache Spark >
        • SparkCode
        • Sample1
        • DataFrames
        • RDDs
        • SparkStreaming
        • SparkFiles
    • Integration >
      • Apache Camel
    • Testing Frameworks >
      • JUnit >
        • JUnit Runners
      • EasyMock
      • Mockito >
        • Page 2
      • TestNG
    • Blockchain >
      • Ethereum Smart Contract
      • Blockchain Java Example
    • Microservices >
      • Design Patterns
    • AWS >
      • Honeycode
  • Databases
    • Oracle >
      • Interview1
      • SQL Queries
    • Elastic Search >
      • StudySources
  • Random issues
    • TOAD issue
    • Architect's suggestions
    • ApacheSpark Installation
  • Your Views
I got the online coding questions as part of interview process in ECS.
I was told next day that I have cleared the coding round & scored full marks. I wondered, as I knew I had not covered all the scenarios. Next round was telephonic round from UK. This discussion was around the behavioural side to understand your work & how did you handle the difficult team members in your team. It was of no use as per my understanding.
I have been through many interviews & believe me, no interviewer is ready to accept his/her creepy truth nor ready to hear honest words from you. All these people need/want to listen some cheesy/fancy/catchy technical words from you, which I believe that 90% candidates had not used in their career ever or not even listened before that interview. As many candidates mug-up some such words, definitions & have planned some story to relate with those words during their interviews.
So only one suggestion - If you really want some job, then screw the honesty & be ready with some fancy technical words, definitions & some story where you can use those words weave some of your work around that.
Now, for this I got 2 coding questions -
Question 1) You are given a number M such that some array will be having M balls each having value 1..M, i.e. ball 1 will   
                    have value 1 & ball 2 will have value 2 and so on. Similarly you will be having bag which can hold the balls of  
                    total value of M
                    Another array 'A' will be given having some numbers such numbers <=M
                    'A' denotes the balls which shouldn't be considered. And you have to fill the bag with remaining balls such that 
                    you can have maximum number of balls in the bag but its total value shouldn't exceed M. You need to return that 
                    maximum numbers which this bag can hold.
Solution :

import java.util.ArrayList;
import java.util.HashSet;


public class ECS1 {
 static int results=0;
 
 public static void main(String[] args) {
  int[] array = {1,3,5};
  int M = 10;
  int N = 3;
  System.out.println(MaxStones(M, N, array));//Ans 2
 }
 
 public static int MaxStones(int M, int N, int[] array)
    {
        HashSet<Integer> common = new HashSet<>();
        HashSet<Integer> bag = new HashSet<>();
        ArrayList<Integer> unique = new ArrayList<Integer>();
       
        for(int i : array) {
            common.add(i);
        }
       
        for(int i = 1; i <= M; i++) {
            if(!common.contains(i)) {
                unique.add(i);
            }
        }
       
        int len = unique.size();
       
        for(int i = 0; i < len; i++) {
            int rem = M;
            bag.clear();
            if(unique.get(i) <= M) {
                rem-=unique.get(i);
                bag.add(unique.get(i));
                find(i+1, len, rem, bag, unique);
                if(bag.size() > results) {
                 results = bag.size();
                }
            } else
            break;
        }
       
        return results;
    }
 
 public static void find(int N, int len, int rem, HashSet<Integer> bag, ArrayList<Integer> unique) {
        for(int i = N; i < len; i++) {
            if(rem > 0 && unique.get(i) <= rem) {
                rem -= unique.get(i);
                bag.add(unique.get(i));
                find(i+1, len, rem, bag, unique);
            } else
            return;
        }
    }
 


}

Question 2) : You are given an array of numbers each denoting individual person type. Now we need to make the groups of  
                      these persons such that each group has at least 2 persons having common type to avoid any conflicts in the 
                      group. Provide the maximum number of groups can be created with this constraint, if no such group is possible 
                      then return 0.
Solution :

import java.util.HashMap;

public class ECS2 {
 static int result=0;
 public static void main(String[] args) {
  int[] N_arr = {2,1,3,1,2,2,5,6,2}; //Ans 3
//  int[] N_arr = {1,2,3,4,5,6,1,2}; //Ans 2
  System.out.println(CreateTeam(7, N_arr));
 }

 public static int CreateTeam(int N, int[] N_arr)
 {

  HashMap<Integer, Integer> groups = new HashMap<>();
  for(int i : N_arr) {
   if(groups.get(i) == null) {
    groups.put(i, 1);
   } else {
    int n = groups.get(i);
    groups.put(i, n+1);
   }
  }

  groups.forEach((a,b) -> {
   result+=(b/2);
  });

  return result;
 }

}

Powered by Create your own unique website with customizable templates.