Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2178 of 3363
866 Views
A FileFilter is a functional interface from the "java.io" package. It can be used as the assignment target for a lambda expression or method reference. An instance of the FileFilter interface passed to the listFiles() method of the File class. FileFilter interface having one abstract method accept() and it tests whether or not the specified abstract pathname has included in a pathname list.Syntax@FunctionalInterface public interface FileFilterExampleimport java.io.File; import java.io.FileFilter; public class FileFilterTest { public static void main(String[] args) { File dir = new File("C:/Program Files/Java/jdk1.8.0_211"); File[] subDir = dir.listFiles((file) -> { // lambda expression ... Read More
228 Views
In this problem, we are given a binary tree and we have to print all nodes at a level in sorted order of their values.Let’s take an example to understand the concept better, Input −Output −20 6 15 2 17 32 78To solve this problem, we need to print a sorted order of each level of the tree. For this, we need to create a queue and two priority queues. The NULL separator is used to separate two levels.ExampleProgram to illustrate the logic − Live Demo#include #include #include using namespace std; struct Node { int data; struct ... Read More
158 Views
In this problem, we have to print all the numbers from 0 to n which are Bitwise AND of a binary of n.Let’s take an example to understand the concept better.Input : N = 4. Output : 0 4 Explanation : 0 & 4 = 0 1 & 4 = 0 2 & 4 = 0 3 & 4 = 0 4 & 4 = 4. Input : N = 6 Output : 0, 2, 4, 6To solve this problem, we need to use bitwise operators. Using these we will find the required subsets. We ... Read More
700 Views
In this problem, we are given two nodes of a binary search tree. And we have to print all the values in the range of k1 to k2 that occur in the tree. That is we have to print all the values that are greater than k1 and smaller than k2. And we have to print all these keys in increasing order of their values.Binary Search Tree is a tree which follows these 3 properties −The left subtree has nodes with values lesser than the node’s value.The right subtree has a node with values greater than the node’s value.A subtree’s ... Read More
391 Views
In this problem, we are given expression. And we have to print the bracket number sequence. Let’s look at an example to understand the problem better.Example, Input : ((()())()) Output : 1233442551Explanation − Here we have encountered 5 bracket pairs and we have printed them in a sequence of their[ occurrence.Now since we know about the problem, let’s create a solution to this solution.The solution to this problem requires a stack data structure. We will use one variable that keeps the count of the number of left brackets and stack keeps track of right brackets. We will count left brackets ... Read More
4K+ Views
In this problem, we are given a year and we want to print the calendar for that year.The year calendar shows all days, months on every date of the month. And here we will create a program that will return the calendar of the current year.For this, we will need some calculations like, Number of days in a specific monthJanuary, March, May, July, August, October, December has 31 days.February has 28 days in a nonleap year and 29 days in a leap year.April, June, September, November has 30 days.Start Day (weekday) on the monthBased on the year and month, the ... Read More
573 Views
This problem, We are given a string of lowercase characters. and we have to find the frequencies of each character that occurs in the string. the below example when explaining more about the problem.Input : “jskdk” Output : j 1 s 1 k 2 d 1Explanation − In the String, the characters j, s, d occur once and k occurs twice. Hence, the output printed gives the above result.Now let's create a logic to solve this problem. As stated we have to find the frequency of occurrence of each character in the string. One logical way is to traverse the ... Read More
461 Views
In this problem, we are given string str by the user. And we have to print only those characters whose frequencies of occurrence in an odd number.To solve this problem, we have to find the total frequency of occurrence of a character in a string. And print only those characters of the string that have odd frequencies of occurrence.Let’s take an example to understand the topic better −Input : adatesaas. Output : dteExplanation −The characters with their frequency of occurrence are −a4d1t1e1s2Characters with odd frequency are d, t, e.AlgorithmNow let's try to create an algorithm to solve this problem −Step ... Read More
3K+ Views
C/C++ programming language, the user is provided with functionality to customize the output based on the requirement of the user. C/C++ graphics functions are included in graphics.h header file. Using this library you can create different objects, set the color of text, change the font and size of the text and change the background of the output.Now, let's see the working of all the function to alter the text of the output in c/c++ programming language −setcolor() − This function is used to change the color of the output text.Syntaxsetcolor(int)Example#include #include int main(){ int gdriver = DETECT, gmode, i; ... Read More
776 Views
In this programming problem, we are given two strings. And we have to find all the characters of the string that are common in both the string and we have to print these common characters in alphabetical order. And print ‘NO COMMON CHARACTERS ’ found if no common letters arise. Given that the string does not contain all lower case alphabets.Let’s take an example −Input : string1 : adsfhslf string2 : fsrakf Output : affsExplanation − Between the two strings there are a, f, s. Hence the lexicographical output is ‘afs’.Input : string1 : abcde string2 : glhyte ... Read More