
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
Found 33676 Articles for Programming

1K+ Views
We are given a number N as input. The goal is to count the total number of digits between numbers 1 to N. 1 to 9 numbers require 1 digit each, 11 to 99 require 2 digits each, 100 to 999 require 3 digits each and so on.Let us understand with examplesInput − N=11Output − Count of total number of digits from 1 to N are: 13Explanation − Numbers 1 to 9 has 1 digit each : 9 digits 10, 11 have 2 digits each. 4 digits. Total digits= 9+4=13.Input − N=999Output − Count of the total number of digits ... Read More

261 Views
We are given an array of positive integers. The goal is to find the subarrays of numbers in an array such that each subarray has the sum as prime. If the array is { 1, 2, 3, 4 }. Then subarrays will be {1, 2}, {2, 3}, {3, 4}. Count of such subarrays is 3.Let us understand with examplesInput − arr[] = {1, 3, 5, 3, 2 };Output − Count of subarrays with Prime sum are: 3Explanation − Subarrays will be : { 3, 2} sum=5 prime, {3, 5, 3} sum=11 prime and {3, 5, 3, 2} sum is 13 ... Read More

464 Views
We are given an array of positive integers. The goal is to find the subarrays of numbers in an array such that each subarray has the same number of even and odd elements in it. If the array is { 1, 2, 3, 4 }. Then subarrays will be {1, 2}, {2, 3}, {3, 4}, {1, 2, 3, 4}. Count of such subarrays is 4.Let us understand with examplesInput − arr[] = {1, 3, 5, 7, 8, 3, 2 };Output − Count of subarrays with same even and odd elements are − 4Explanation − Subarrays will be − { 7, ... Read More

233 Views
We are given string str and a substring sub_str of length 3. The goal is to find the count of subsequence sub_str in str. Example “act” is thrice in “cataract” ( cataract, cataract, cataract ).Let us understand with examples.Input − str= “settlement” sub_str=”set”Output − Count of a subsequence of length three in a given string are: 5Explanation − Subsequences will be −1. set tlement, 2. se t t lement, 3. se ttlemen t, 4. s ettl e men t, 5. settlem e n tInput − str= “knowledge” sub_str=”now”Output − Count of a subsequence of length three in a given string ... Read More

256 Views
We are given an array of positive integers. The goal is to find the subsets of numbers in an array such that each subset has distinct even numbers in it. All sets with the same elements will be counted as 1. [2, 4, 6] and [6, 2, 4] are the same set.Let us understand with examplesInput − arr[] = {1, 3, 5, 7, 8, 3, 2 };Output −Count of subsets having distinct even numbers are − 3Explanation − Subsets will be − [2], [8], [2, 8]Input − arr[] = {2, 4, 6 };Output −Count of subsets having distinct even numbers ... Read More

463 Views
We are given string str. The goal is to count the number of substrings in str that have starting character same as character X and ending character same as character Y. For example, if input is “artact” and X=’a’ and Y=’t’, the substrings will be “art”, “act”, “artact”. The count is 3.Let us understand with examples.Input − str=”abcccdef” X=’a’ Y=’c’Output −Count of substrings that starts with character X and ends with Y is − 3Explanation − Substrings will be“abc”, “abcc”, “abccc”. Total 3.Input − str=”tempest” X=’t’ Y=’t’Output − Count of substrings that starts with character X and ends with Y ... Read More

346 Views
We are given a string str. The goal is to count the number of substrings in str that have each character occurring utmost k times. For example if input is “abc” and k=1, the substrings will be “a”, “b”, “c”, “ab”, “bc”, “abc”.Let us understand with examples.Input − str=”abaefgf”Output − Count of substrings with same first and last characters are &mmius; 9Explanation − Substrings will be“a”, “b”, “a”, “e” ,”f”, “g”, “f”, “aba”, “fgf”. Total 9.Input − str=”abcdef”Output − Count of substrings with same first and last characters are: 6Explanation − Substrings will be -“a” , “b” , “c”, “d”, ... Read More

537 Views
We are given a string str. The goal is to count the number of substrings in str that have the same starting and ending character. For example, if input is “baca” substrings will be “b”, “a”, “c”, “a”, “aca”. Total 5.Let us understand with examples.Input − str=”abaefgf”Output −Count of substrings with same first and last characters are: 9Explanation − Substrings will be“a”, “b”, “a”, “e” ,”f”, “g”, “f”, “aba”, “fgf”. Total 9.Input − str=”abcdef”Output −Count of substrings with same first and last characters are: 6Explanation − Substrings will be −“a” , “b” , “c”, “d”, “e” ,”f”. Total 6The approach ... Read More

405 Views
We are given string str containing 0’s, 1’s, and 2’s only. The goal is to find all substrings of str that have equal numbers of 0’s 1’s and 2’s. If str is “12012”. Substrings with equal 0’s, 1’s, and 2’s will be “120”, “201” and “012”. The count will be 3.Let us understand with examples.Input − str=”112200120”Output −Count of Substrings with an equal number of 0s, 1s, and 2s are − 5Explanation − Substrings will bestr[0-5]=”112200”, str[1-6]=”122001”, str[5-7]=”012”, str[6-8]=”120”, str[7-0]=”201”Input − str=”12012”Output −Count of Substrings with an equal number of 0s, 1s, and 2s are: 3Explanation − Substrings will be ... Read More

220 Views
We are given with two strings str_1 and str_2 as input. The goal is to find the count of strings same as str_2 that can be constructed using letters picked from str_1 from which each character is used just once.Note − All alphabets in both are in the same case.Let us understand with examples.Input − str_1 = "abcaaaabca", str_2 = "bca";Output − Count occurrences of a string that can be constructed from another given string are: 2Explanation − Substrings bca in str_a −str_1[1-3]=”bca” and str[7-9]=”bca”Input − str_1 = "about", str_2 = "cout";Output − Count occurrences of a string that can ... Read More