Nitin Agrawal
Contact -
  • Home
  • Interviews
    • Secret Receipe
    • InterviewFacts
    • Resume Thoughts
    • Daily Coding Problems
    • BigShyft
    • CompanyInterviews >
      • InvestmentBanks >
        • ECS
        • Bank Of America
        • WesternUnion
        • WellsFargo
      • ProductBasedCompanies >
        • CA Technologies
        • Model N India
        • Verizon Media
        • Oracle & GoJek
        • IVY Computec
        • Nvidia
        • ClearWaterAnalytics
        • ADP
        • ServiceNow
        • Pubmatic
        • Expedia
        • Amphora
        • CDK Global
        • CDK Global
        • Epic
        • Sincro-Pune
        • Whiz.AI
        • ChargePoint
      • ServiceBasedCompanies >
        • Altimetrik
        • ASG World Wide Pvt Ltd
        • Paraxel International & Pramati Technologies Pvt Ltd
        • MitraTech
        • Intelizest Coding Round
        • EPAM
    • Interviews Theory
  • Programming Languages
    • Java Script >
      • Tutorials
      • Code Snippets
    • Reactive Programming >
      • Code Snippets
    • R
    • DataStructures >
      • LeetCode Problems
      • AnagramsSet
    • Core Java >
      • Codility
      • Program Arguments OR VM arguments & Environment variables
      • Java Releases
      • Threading >
        • ThreadsOrder
        • ProducerConsumer
        • Finalizer
        • RaceCondition
        • Executors
        • Future Or CompletableFuture
      • Important Points
      • Immutability
      • Dictionary
      • URL Validator
    • Julia
    • Python >
      • Decorators
      • String Formatting
      • Generators_Threads
      • JustLikeThat
    • Go >
      • Tutorial
      • CodeSnippet
      • Go Routine_Channel
      • Suggestions
    • Methodologies & Design Patterns >
      • Design Principles
      • Design Patterns >
        • TemplatePattern
        • Adapter Design Pattern
        • Decorator
        • Proxy
        • Lazy Initialization
        • CombinatorPattern
        • RequestChaining
        • Singleton >
          • Singletons
  • Frameworks
    • Apache Velocity
    • Spring >
      • Spring Boot >
        • CustomProperties
        • ExceptionHandling
        • Issues
      • Quick View
    • Rest WebServices >
      • Interviews
      • Swagger
    • Cloudera BigData >
      • Ques_Ans
      • Hive
      • Apache Spark >
        • ApacheSpark Installation
        • SparkCode
        • Sample1
        • DataFrames
        • RDDs
        • SparkStreaming
        • SparkFiles
    • Integration >
      • Apache Camel
    • Testing Frameworks >
      • JUnit >
        • JUnit Runners
      • EasyMock
      • Mockito >
        • Page 2
      • TestNG
      • Gatling
    • Blockchain >
      • Ethereum Smart Contract
      • Blockchain Java Example
    • Microservices >
      • Messaging Formats
      • Design Patterns
    • AWS >
      • Honeycode
    • Dockers >
      • GitBash
      • Issues
  • Databases
    • MySql
    • Oracle >
      • Interview1
      • SQL Queries
    • Elastic Search
  • Random issues
    • TOAD issue
    • Architect's suggestions
  • Your Views

Google

5/28/2022

2 Comments

 
This problem was asked by Google.
Given an array of strictly the characters 'R', 'G', and 'B', segregate the values of the array so that all the Rs come first, the Gs come second, and the Bs come last. You can only swap elements of the array.
Do this in linear time and in-place.
For example, given the array ['G', 'B', 'R', 'R', 'B', 'R', 'G'], it should become ['R', 'R', 'R', 'G', 'G', 'B', 'B'].

Below are the 2 ways I tried to solve, one is in-place & other one is not.
In one relative order is maintained & in other is not maintained.
The solution is not efficient one & neither it is in Linear time, so if anyone knows the
​answer, pls comment
.
Swap Elements

    
 If we see in such problems, primitive type data is used & there order shouldn't matter like this 
'R' should come before that 'R'. If interviewer is putting this constraint then that person has 
seen the similar problem in different context & trying to use the same constraint to confuse you
& show him/herself as smarter person.
 Even in Google like companies, such questions for certain scenario are prepared after some
analysis and preparation which they expect the candidates to solve during interviews.
 So never assume that MAANG companies have higher standards, rather it is more like
marketing strategy to place itself as unique one.
 Well, for this problem to solve in linear time & in-place, & without doing swapping like shown
above, we can do the counting & the populate the existing array, like shown below.
 And this way it is quite faster than the above ways, means it is applicable if you are having
primitive type data. Plus this way will work for other problem where you will be asked to have
0s & ​1s in similar order.
Counting Swap

    
 Just thinking if I can avoid some iteration part...
So tried like shown below, please comment-
Counting Swap

    
2 Comments

Facebook

1/9/2022

4 Comments

 
As per Daily Coding Problem
This problem was asked by Facebook.
Write a function that rotates a list by k elements.
For example, [1, 2, 3, 4, 5, 6] rotated by two becomes [3, 4, 5, 6, 1, 2].
Try solving this without creating a copy of the list.
​How many swap or move operations do you need?

Below, I think can be a way to write the code for this, please suggest the better way-

    
4 Comments

Nvidia

10/27/2021

1 Comment

 
 As per this website below problem was asked in Nvdia & has been tagged as 'Hard'
 It is actually not only Hard but impossible to solve if one doesn't know the trick.
 Though Google search can easily solve that problem
 Find the maximum of two numbers without using any if-else statements, branching, or direct
 comparisons

 & below is that solution, please suggest if it fails -
Find Min & Max

    
1 Comment

Facebook

10/26/2021

2 Comments

 
This problem was asked by Facebook as per Daily Coding Problem.
Given a string and a set of delimiters, reverse the words in the string while maintaining the relative order of the delimiters. For example, given "hello/world:here", return "here/world:hello"
Follow-up: Does your solution work for the following cases: "hello/world:here/", "hello//world:here"

Note :- I don't agree with above Follow-up point as relative order is changing, I think so.
            So either 1st example is correct or the Follow-up example. For below solution I am
            considering first example as the correct one.

    
2 Comments

    Author

    Nitin Agrawal

    Archives

    May 2022
    January 2022
    October 2021

    Categories

    All

Powered by Create your own unique website with customizable templates.