Posts

Real time speech blocker

This post is in transit.

How to sort String array by length of each string present in an array

public class SortStrings { public static void main(String args[]) { String strarr[] = { "twersaoo", "threee", "one", "asjhgiqwg", "ahma djh", "h", "ajsvd", "abnbavs", "nbvvd" }; String result[] = method(strarr); for (int i = 0; i < result.length; i++) { System.out.println(result[i]); } } public static String[] method(String str[]) { for (int i = 0; i < str.length; i++) { for (int j = 0; j < str.length - 1; j++) { if (str[j].length() > str[j + 1].length()) { String temp = str[j]; str[j] = str[j + 1]; str[j + 1] = temp; } } } return str; } }

Multimedia search engine using python

Image
Sometimes we remember people not by their name but by what they said. Today, i have created application using python which can search videos and audios on the basis of speech / dialogues said in them. Suppose you know famous dialogue of movie but can't remember the name of that movie. In this case you can directly search that movie by any dialogue which you remember from it. Consider the example shown in following image - I searched "thanos did exactly what he said" and it listed the trailer of avengers endgame where this dialogue is. For now this application is able to find local multimedia files only. I am working on how to make it search globally

How to program to print first non repeated character from String?

One of the most common string interview questions: Find the first non-repeated (unique) character in a given string. for Example, if given String is  "Morning"  then it should print "M". This question demonstrates the efficient use of the hash table data structure. public class Main { static String str = "MMorning"; static char c[] = str.toCharArray(); public static void main(String[] args) { for (int i = 0; i < c.length; i++) { char check = c[i]; int number = 0; for (int j = 0; j < c.length; j++) { if (check == c[j]) { number++; } if (number > 1) { break; } } if (number == 1) { System.out.println(check); break; } } } }

How to check if two Strings are anagrams of each other?

A simple coding problem based upon String, but could also be asked with numbers. You need to write a Java program to check if two given strings are anagrams of Each other. Two strings are anagrams if they are written using the same exact letters, ignoring space, punctuation, and capitalization. Each letter should have the same count in both strings. For example, the  Army  and  Mary  are an anagram of each other. public class Main { static String one = "seyseysey"; static String two = "yesesyyes"; static char cone[] = one.toCharArray(); static char ctwo[] = two.toCharArray(); static boolean status = false; public static void main(String[] args) { for (int i = 0; i < cone.length; i++) { char check = cone[i]; int number = 0; for (int j = 0; j < cone.length; j++) { if (check == cone[j]) { number++; } } if (stringCheck(check, number) != number) { status = false; break; } else { status = tr...

Shift 1's to right and 0's to left for the given int array

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter length of array"); int l = sc.nextInt(); System.out.println("Enter " + l + " elements one by one into array"); int arr[] = new int[l]; for (int i = 0; i < l; i++) { arr[i] = sc.nextInt(); } for (int i = 0; i < arr.length; i++) { if (arr[i] == 1) { System.out.print(arr[i]); } } for (int i = 0; i < arr.length; i++) { if (arr[i] == 0) { System.out.print(arr[i]); } } sc.close(); } } Input -  Enter length of array 7 Enter 7 elements one by one into array 1 0 0 1 1 0 1 Output -  1111000