Skip to content

Latest commit

 

History

History
190 lines (157 loc) · 12.8 KB

File metadata and controls

190 lines (157 loc) · 12.8 KB

This repository will contain all the java, spring, hibernate, mysql, elastic search, thread, related questions.

Java

Spring

Hibernate

http://hibernate.org/orm/documentation/5.4/

MySql

Rest API

Elastic Search

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html

Design Pattern

Maven

AWS

Microservice

PUZZLE

MISC

Competitive Programming

  • Find 2nd lagest number in an array? Input: {23,10,34,23,20} -> output: 23
      set arr = [23,10,34,23,20]
      int lengthOfArray = arr.length();
      int max = 0;
      int secondMax = 0;
      for(int i=0;i<lengthOfArray;i++){
      if(arr[i]>max){
      secondMax = max;
      max= arr[i];
      }
    
      s.o.p(secondMax);
    
      }
    
  • Occurance count string = "AAABBCCCDDAACCEE" then ouput : 3A2B3C2D2A2C2E
          public class Main
        {
            public static void main(String[] args) {
    
                String str = "AAABBCCCDDAACCEE";
                int strLength = str.length();
                char ch = str.charAt(0);
                int counter = 0;
                for(int i=0;i<strLength;i++){
                    if(ch == str.charAt(i)){
                        counter=counter+1;
                        continue;
                    } else {
                        System.out.print(counter);
                        System.out.print(ch);
                        counter = 1;
                        ch = str.charAt(i);
                    }
                }
                System.out.print(counter);
                System.out.print(ch);
            }
        }
    
  • all permutation of a string = "ABC" then ouput : ABC, ACB, BAC, BCA, CAB, CBA