Skip to content

Records are meant to be Broken, I will try to give my 120% effort

Notifications You must be signed in to change notification settings

MaheshReddy-05/DSA_Coding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSA_Coding

Currently working on it will come back with a bang bang ..... ! Don't forget to star A lot of content is going to be here

Character Shortcuts

String Shortcuts

char ch[] = s.toCharArray();

  • Char Array to String
    Adding all char array character to a single string String.valueOf(chararr);

String Builder

  • Reversing a string StringBuilder s = new StringBuilder("String"); s.reverse()

Array Shortcuts

  • Converting Arrays to list You can only convert wrapper class to list Integer arr[] = {blah....}; list<Object> al = Arrays.asList(arr);

  • Array fill
    Filling array with same number
    Array.fill(arr,-1);

  • Array Equal Return boolean comparing arrays
    Arrays.equals(arr1,arr2);

  • Array Sort Sorting array
    Arrays.sort(arr);

  • Array BinarySearch Searching a number using binarySearch
    Arrays.binarySearch(arr,10);

HashMap

  • Enhanced Get Element Used in insertion of frequency
    hm.getOrDefault(arr[i],0)+1 ;
    hm.put(arr[i],hm.getOrDefault(arr[i],0)+1)
  • Iterator
    HashMap<Integer,String> languages;
    for (Entry<Integer,String> entry : languages.entrySet()) {
    System.out.print(entry.getKey());
    System.out.print(entry.getValue());
    }

PriorityQueue

  • MIN Heap
    PriorityQueue<Integer> pq = new PriorityQueue<>((a,b)->a-b);
  • MAX Heap
    PriorityQueue<Integer> pq = new PriorityQueue<>((a,b)->b-a);

Comparator

Easy Syntax

  • If statement return a value
    (a>b) ? true : false ;

  • String T to T
    Double.parseDouble("1.223") Integer.parseInt("123") Float.parseFloat("23.23")

  • Decimal after point till x
    double d1 = 1.23232
    DecimalFormat df = new DecimalFormat()
    d1 = df.format(d1)

About

Records are meant to be Broken, I will try to give my 120% effort

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages