educative.io

Educative

Unable to execute DIY problems

Hello,

I am unable to execute any of the DIY problems in decoding the coding interview-java course after it got updated.
I have created a separate ticket with the name result-variable-hidden-error but its still not resolved, i have shared the details as well.

I have an interview coming up and i am actively using your platform to prepare, but since past few days i am unable to do so. Please let me know when it will be fixed


Type your question above this line.

Course: https://www.educative.io/collection/10370001/4938268330688512
Lesson: https://www.educative.io/collection/page/10370001/4938268330688512/6124218604847104

Hello @Pranjali_Choudhary ,
Can you please share your code here which is causing an error?

class Solution {
public static boolean validUtf8(int[] data) {
    int numberOfBytesToProcess = 0;
    int mask1 = 1 << 7;
    int mask2 = 1 << 6;
    for(int i=0;i<data.length;i++) {
        if(numberOfBytesToProcess==0) {
            int mask = 1 << 7;
            while((mask & data[i])!= 0) {
                numberOfBytesToProcess+=1;
                mask = mask >> 1;
            }
            if(numberOfBytesToProcess==0) {
                continue;
            }
            if(numberOfBytesToProcess>4 || numberOfBytesToProcess==1) {
                return false;
            }
        } else {
            if(!((data[i] & mask1)!=0 && (mask2 & data[i])==0)) {
                return false;
            }
        }
        numberOfBytesToProcess-=1;
    }
    return numberOfBytesToProcess==0;
}
}

Also this one in DIY: Alien Dictionary - Decode the Coding Interview in Java: Real-World Examples

    class Solution {
  public static String alienOrder(String[] words) {
    Map<Character, List<Character>> adjList = new HashMap<Character, List<Character>>();
    Map<Character, Integer> counts = new HashMap<>();
    for(String word: words) {
      for(char c: word.toCharArray()) {
        counts.put(c,0);
        adjList.put(c, new ArrayList<Character>());
      }
    }

    for(int i=0;i<words.length-1;i++) {
      String word1 = words[i];
      String word2 = words[i+1];
      if(word1.length()>word2.length()  && word1.startsWith(word2)) {
        return "";
      }
      for(int j=0;i<Math.min(word1.length(),word2.length());j++) {
        if(word1.charAt(j) != word2.charAt(j)) {
          adjList.get(word1.charAt(j)).add(word2.charAt(j));
          counts.put(word2.charAt(j),counts.get(word2.charAt(j))+1);
          break;
        }
      }
    }
    StringBuilder result = new StringBuilder();
    Queue<Character> queue = new LinkedList<>();
    for(Character c: counts.keySet()) {
      if(counts.get(c).equals(0)) {
        queue.add(c);
      }
    }
    while(!queue.isEmpty()) {
      Character c = queue.remove();
      result.append(c);
      for(Character next: adjList.get(c)) {
        counts.put(next,counts.get(next)-1);
        if(counts.get(next).equals(0)) {
          queue.add(next);
        }
      }

    }
    if(result.length()<counts.size()) {
      return "";
    }
    return result.toString();
  }
}

Thank you, Working on the issue, will update you soon.

is this issue fixed?

Yes @Pranjali_Choudhary , the issue has been fixed now. You can check any DIY, if you face any issue again, feel free to post here again.
If you face the same issue in the following DIY’s, click on the reset button after saving your code in the widget.

Thanks and regards