Przejdź do głównej zawartości

Learning by doing - Java - 50+ Interview Questions for Programmers

Learning by doing - Java - 50+ Interview Questions for Programmers



50+ Interview questions for 50+ days ? We will see ;) Risky resolution but method "learning by doing" is great!!

First are coming questions regarding Arrays:
  1. How do you find the missing number in a given integer array of 1 to 100? (solution)
  2. How do you find the duplicate number on a given integer array? (solution)
  3. How do you find the largest and smallest number in an unsorted integer array? (solution)
  4. How do you find all pairs of an integer array whose sum is equal to a given number? (solution)
  5. How do you find duplicate numbers in an array if it contains multiple duplicates? (solution)
  6. How are duplicates removed from a given array in Java? (solution)
  7. How is an integer array sorted in place using the quicksort algorithm? (solution)
  8. How do you remove duplicates from an array in place? (solution)
  9. How do you reverse an array in place in Java? (solution)
  10. How are duplicates removed from an array without using any library? (solution)

Komentarze

Popularne posty z tego bloga

Skrócony zapis if - instrukcja warunkowa java

Instrukcja warunkowa - warunek i rezultat. if (warunek) { jesli spełniony wykonań operacje i zwróć wynik; } warunek nie spełniony Możliwości skrócenia kodu instrukcji warunkowej if (i < 0) ? i-- : i++; Jeżeli i mniejsze od zera to i-- jezeli false to i++ if (i < 0) {     i--; } else {     i++; } Skrócony zapis instrukcji warunkowej else if (i < 0) ? i--;  inna_zmienna=4; : i++; if (i < 0) {     i--; } else {     i++;     inna_zmienna = 4; } Skrócony zapis if

String-1 > endsLy

Given a string, return true if it ends in "ly". endsLy("oddly") → true endsLy("y") → false endsLy("oddy") → false public boolean endsLy ( String str ) { if ( str . length ()< 2 ){ return false ; } if (( str . substring ( str . length ()- 2 , str . length ())). equals ( "ly" )){ return true ; } return false ; }

String-1 > withouEnd2

Given a string, return a version without both the first and last char of the string. The string may be any length, including 0. withouEnd2("Hello") → "ell" withouEnd2("abc") → "b" withouEnd2("ab") → "" public String withouEnd2 ( String str ) { if ( str . length ()== 1 ){ return str . substring ( 1 ); } else if ( str . length ()== 0 ){ return str ; } return ( str . substring ( 1 , str . length ()- 1 )); }