Nitin Agrawal
Contact -
  • Home
  • Interviews
    • Secret Receipe
    • InterviewFacts
    • Resume Thoughts
    • Daily Coding Problems
    • BigShyft
    • Companies
    • Interviews Theory
  • Programming Languages
    • Java Script >
      • Tutorials
      • Code Snippets
    • Reactive Programming >
      • Code Snippets
    • R
    • DataStructures >
      • LeetCode Problems >
        • Problem10
        • Problem300
      • AnagramsSet
    • Core Java >
      • Codility
      • Program Arguments OR VM arguments & Environment variables
      • Java Releases >
        • Java8 >
          • Performance
          • NasHorn
          • WordCount
          • Thoughts
        • Java9 >
          • ServiceLoaders
          • Lambdas
          • List Of Objects
          • Code Snippets
        • Java14 >
          • Teeing
          • Pattern
          • Semaphores
        • Java17 >
          • Switches
          • FunctionalStreams
          • Predicate
          • Consumer_Supplier
          • Collectors in Java
        • Java21 >
          • Un-named Class
          • Virtual Threads
          • Structured Concurrency
      • Threading >
        • ThreadsOrder
        • ProducerConsumer
        • Finalizer
        • RaceCondition
        • Executors
        • Future Or CompletableFuture
      • Important Points
      • Immutability
      • Dictionary
      • Sample Code Part 1 >
        • PatternLength
        • Serialization >
          • Kryo2
          • JAXB/XSD
          • XStream
        • MongoDB
        • Strings >
          • Reverse the String
          • Reverse the String in n/2 complexity
          • StringEditor
          • Reversing String
          • String Puzzle
          • Knuth Morris Pratt
          • Unique characters
          • Top N most occurring characters
          • Longest Common Subsequence
          • Longest Common Substring
        • 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 >
        • TemplatePattern
        • Adapter Design Pattern
        • Proxy
        • Lazy Initialization
        • CombinatorPattern
        • Singleton >
          • Singletons
        • Strategy
  • Frameworks
    • Apache Velocity
    • React Library >
      • Tutorial
    • Spring >
      • Spring Boot >
        • CustomProperties
        • ExceptionHandling
        • Custom Beans
        • 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
    • Blockchain >
      • Ethereum Smart Contract
      • Blockchain Java Example
    • Microservices >
      • Messaging Formats
      • Design Patterns
    • AWS >
      • Honeycode
    • Dockers >
      • GitBash
      • Issues
      • Kubernetes
  • Databases
    • MySql
    • Oracle >
      • Interview1
      • SQL Queries
    • Elastic Search
  • Random issues
    • TOAD issue
    • Architect's suggestions
  • Your Views

Round 1

Question 1: You are given a string : sfdgjdg3e67jgjyg456
                    Fetch all numbers & provide their sum. Write the code such that if there is any slight change of requirements then                      there should be minimum code change for that.

Question 2 : Remove duplicates from the array of elements.

Question 3 : Add the given 2 numbers & these numbers are so large that can't be represented by any numeric type.

Round 2

Question 1 : How to efficiently find the given alphanumeric value in the array of millions of such numbers & if not present then 
                    add it in the array.

Question 2 : Z -> 1...9
                    Find Z such that ZZ+ZZ+Z+Z+Z = 100

Question 3 : A, B , C-> 1...9
                    Find A & B such that AB*AB = CAB

Question 4 : ​Design the chess board
Then I was told by their recruiter that both the rounds are cleared & they don't have panel for next round, so I need to come again after 2-3 days. But I didnt get any response for 1 week, & when I enquired for that multiple times then I got the response that my profile is not shortlisted for further discussions. Strange...
​

Fast forward to 2022, I had one more discussion & had first coding round in which I was asked-
Implement the custom stack to get the most occurring number & if there is tie then get the number occurred last.

Though I was not able to provide the optimal approach but with the help of interviewer I was able to give almost working code.
And the below approach was due to the help of interviewer as I was not able to think about it.
So below, I have given my way of implementation of that approach. So at least this time experience was good as interviewer
behaved well & it was not like previous experiences with ServiceNow interviews.
Please comment & suggest the better approach or implementation-
Picture
Well, I got one comment stating that I am not handing the exception when stack is empty, though I don't know what to do by handling the exception, if it happens. So one can also get the same comment during interview & believe many interviewers will be having the mindset of using either some try/catch or throw some other exception if stack is empty.
But my say is, if you are using jdk1.8+, which you will be, then why don't you use Optional here & let the client decide about the exception on his/her side.
So can have the above pop() function as shown below-
Picture
Powered by Create your own unique website with customizable templates.