Java Coding Interview Practice on Pramp

preview_player
Показать описание

In this session, the asked questions are:
- Root of number
- Smallest substring of all Character

Pramp makes interview prep simple so you can focus on getting dramatically better at interviewing!

Join us and start practicing coding interviews today -

Socials:
Рекомендации по теме
Комментарии
Автор

I got hired yesterday after the same interview. Im flying to Kanzas city on March 29th as a Big data middle.

ТюзМайский
Автор

One of my favorite sites, some questions are insanely hard though. Like number of islands, sudoku checker etc. I need to study more.

colorfulcodes
Автор

I did it by finding the permutations of the array and check if the target string contains such permutation, check heap algorith

mks
Автор

A more efficient way to solve the root question assuming we want to find-by-approximating, and not just using Math.pow(x, 1/(double)n), would be:

static double root(double x, int n) {
double guess = x;
while (Math.abs(Math.pow(guess, n) - x) >
guess -= (Math.pow(guess, n)-x)/(n*Math.pow(guess, n-1));
return guess;
}

this converges faster towards the actual root. :)

helikopeter
Автор

As far as live coding interviews please don't stay quiet at any time. Let the interviewer know what you are thinking. Let them know your thought process . Read aloud. Yes you are answering a question, but you have the interviewer to help you.

nemesisc
Автор

+Pramp - Live Coding Interview Practice

killakev
Автор

why is ti called java coding interview its problem solving interview.

nihadogresevic
Автор

The best solution would be pow of 1.0/n.

Anyway, your root solution doesn't solve the problem, you should think on special cases. Follow some observations:
- It will solve root of 1 but will take much longer than needed.
- In case of root of a number between 0 and 1 it will never find the result because the result will be higher than the number.

leobruekers
Автор

static double root(double x, int n) {
return Math.pow(x, 1.0/n);
}
This would of been easier since u were allowed to use the power function

markvolkov
Автор

What kind of questions would be asked for a user with their settings set to less than a year of experience as an engineer? Would we need to discuss the Big-O Notation?
I'm using the Pramp platform to prepare for a junior front-end role, just so you know my background. Thanks in advance!

kenn
Автор

Solution for the Smallest Substring of all Characters:

public static boolean evaluate(String s, char[] tab)
{
boolean result = true;
boolean tmp = false;
if (s.length() == tab.length) {
for (int j = 0; j < tab.length; j++) {
tmp = false;
for (int i = 0; i < tab.length; i++) {

tmp = (tmp ^ (tab[j] == s.charAt(i)));
}
result = result && tmp;
if (result ==false) return result;

}
return result;
}
return false;
}


private static List<Integer> getOccurrences(String s, char c)
{
List<Integer> result= new ArrayList();
System.out.println(s +" lenght: " +s.length() );
for (int i = 0; i < s.length(); i++)
{ "+s.charAt(i));
if ((s.charAt(i) == c))
{
result.add(i);
}
}

return result;
}

private static String arr, String str) {

String strResult ="";
int k = arr.length ;
String tmp;
System.out.println(arr[0]);
List<Integer> Occurrences = getOccurrences(str, arr[0]);
for (int i=0; i<Occurrences.size(); i++) {
" + Occurrences.get(i));
int l = -1;
for (int r = k - 1; r >=0; r--) {
l++;
if ((Occurrences.get(i) - r >= 0) && (Occurrences.get(i) + l < str.length())) {
tmp = - r, Occurrences.get(i) + l+1);
" + tmp);
if (evaluate(tmp, arr))
return tmp;
}
" + Occurrences.get(i));
}
}
return strResult;
}

foottounsi
Автор

I just realised, Im not made to be a programmer..
I will probably do the System Engineering Degree first and go into Web Development later.
Since I really think, programming is really hard and rn I don't think I can handle all the pressure.

RabbitConfirmed
Автор

There is very less questions on pramp.com, I am running out of questions

ManishKumar-upyj
Автор

Interesting approach of testing, but this is not a good way of testing a developer/programmer. This test is very uncomfortable and annoying, at least for me.

leonardvictorio
Автор

I am confused ..who shares the screen interviewer or inteviewee

vaghii
Автор

It is a horrible way to test developers.

erikalves
Автор

public static String arr, String str) {
String result = "";
//str must be longer than unique character set
if (arr.length > str.length()) {
return result;
}
//For each possible substring
//Store arr elements in this hash
//Remove them as you find them in str
HashSet<Character> punchList;

int subStrSize = arr.length;
int strSize = str.length();
//for each size of substring arr.len to str.len
//We start with arr.len because we want to find the shortest substring
for (int currSize = subStrSize; currSize < strSize; currSize++) {
//test for currSize length subStr
//iterate all possible currSize strings
//
for (int strStart = 0; strStart <= strSize - currSize; strStart++) {
punchList = buildPunchList(arr);
int end = strStart + currSize;
StringBuilder subStr = new StringBuilder();
for (int k = strStart; k < end; k++) {
char c = str.charAt(k);
subStr.append(c);
//remove chars I've seen
punchList.remove(c);
}
//punchList is empty, so I saw all available chars
//therefore we have the first shortest solution
if (punchList.size() == 0) {
return subStr.toString();
}
}
}
return result;
}

shellysmith
Автор

do these people know that they are being uploaded to pramp's youtube channel? I'm worried, I have done many interviews naked on pramp and I don't want to appear on their youtube videos

Calisby
Автор

Why is it that the first person can see the solution while answering, but the second person can't?

dorokei
Автор

Hey, nice job guys. I solved the second problem in Swift. I only used one while loop so I believe it's a linear O(n) solution. Let me know what you guys think.

func [Character], str: String)->String{
    guard !str.isEmpty || !uniqueCharacters.isEmpty else {return ""}
    var index = 0
    let sorted = uniqueCharacters.sorted()
    let stringArray = Array(str)
    let lastRange = stringArray.count - sorted.count
    
    while index < lastRange{
        if sorted == + index].sorted() {
            return + index])
        }
      index += 1
    }
  
    if == sorted{
        return
    }
    else{
        return ""
    }
}
["x", "y", "z"], str: "xyyzyyxzx")      //Should return "yxz"

killakev