Valid Pickup and Delivery options

Given N orders, each order consists of pickup and delivery services, means delivery of a particular service will after the pick up of the same service so the sequence pickup/delivery such that delivery(i) is after pickup(i). Write a program to count all valid pickup/delivery possible sequences Since the answer may be too large, return it … Read more Valid Pickup and Delivery options

Print Top 10 videos from List

Given a list L of video names and their watch rates, write a function that will return the videos with the top 10 watch rates. Video names may appear more than once. Example: Input: [abc : 10] [def : 20] [abc : 15] [ghi : 50] [xyz : 100] [abc : 25] [jkl : 10] … Read more Print Top 10 videos from List

Compare two version numbers of a software

Given two versions of a software, write an algorithm to find out which version is the latest. Example: Version A: 1.1.0 Version B: 1.1.1 Given version B latest than version A Version A: 1.2.1 Version B: 1.2.1 Given versions are the same Version A: 2.2.0 Version B: 2.2 Given versions are the same Version A: … Read more Compare two version numbers of a software

The largest number can be formed from the given number

Given a number write an algorithm to construct the largest number possible by using the digits of given number. Given number could be a negative number as well.  Example: Given Input: 34277765 Output: 77765432 Given Input: -342765 Output: -234567 Given Input: 0 Output: 0 Given Input: 2034 Output: 4320 Approach: Sorting Check if the given … Read more The largest number can be formed from the given number

Minimum number of adjacent swaps to sort the given array

Given an array of integers, you are allowed to swap only adjacent elements in the array. write a program to find the minimum number of swaps to sort the given array. Example: Input[] : [2, 20, 15, 6, 10] Minimums adjacent swaps required sort the array: 5 Input[] : [10, 3, 4, 2, 5, 7, … Read more Minimum number of adjacent swaps to sort the given array

Minimum number of times String A is repeated to such that B is substring of A

Given a string A consisting of n characters and a string B consisting of m characters, write a function that will return the number of times A must be stated such that B is a substring of the repeated A. If B can never be a substring, return -1. Example: A = ‘abcd’ B =’cdabcdab’ … Read more Minimum number of times String A is repeated to such that B is substring of A

Print all nested directories and files in a given directory – Recursion

Given a source directory, write a recursive program to print all the nested directories and files in the source directory. Example: [Hellojava] [target] original-Hellojava-1.0-SNAPSHOT.jar [classes] [com] [example] [lambda] [demo] Hello.class [maven-archiver] pom.properties Hellojava-1.0-SNAPSHOT.jar pom.xml Hellojava.iml [src] [test] [java] [main] [resources] [java] [com] Hello.java Approach: Check if given file is directory,  if yes then print its … Read more Print all nested directories and files in a given directory – Recursion

Check if the given playlist of programs is valid

Problem Statement: Given a playlist that contains the list of intervals with the start time, end time and program id. Write a program to validate whether the playlist is valid or not based on certain conditions.  The playlist will be considered invalid if any of the following is true – If any two programs overlap. … Read more Check if the given playlist of programs is valid

Maximum meetings in one room

You have one meeting room at your company. There are N meeting needs to take place. Every meeting has a start time and end time along with the meeting title. Your task is to schedule as many meetings as possible in that conference room with no conflicts.  Example: Meetings: A[ Start Time: 1, End Time: … Read more Maximum meetings in one room

Unresolved references error – Django in PyCharm and IntelliJ

This is a known problem for many. If you are seeing “Unresolved references error” for all the imports of Django as in the image below (either in PyCharm or in IntelliJ) then the Django package is missing. Add Django Package in Intellij  Right click on your project and click on the open module setting. Select … Read more Unresolved references error – Django in PyCharm and IntelliJ

The number of cycles in a given array of integers.

Objective: Given an array of size N which contains integers from range 0 to N-1. (No duplicates). Write a program to find the number of cycles in the array.  Cycles in Array: Since the array is of size N and elements are from 0 to N-1 without any duplicates means all the elements appear exactly … Read more The number of cycles in a given array of integers.

Check if given sudoku is valid or not

Problem: Given a filled sudoku, write a program to check if sudoku is valid or following all of its rules. SUDOKU rules:  Each column contains all of the digits from 1 to 9 only once. Each row contains all of the digits from 1 to 9 only once. Each of the nine 3×3 sub-grid contains … Read more Check if given sudoku is valid or not