Welcome to 1printf(), your ultimate destination for C, C++, Linux, Data Structures, and Microcontroller programming! π
πΉLearn advanced coding techniques in C& C++
πΉMaster Linux internals & shell scripting
πΉDeep dive into Data Structures & Algorithms
πΉExplore Embedded Systems & Microcontrollers (8051,UART, RTOS)
πΉGet hands-on coding tutorials, project ideas,and interview preparation tips
Whether you're a beginner or an experienced programmer, this channel will help you
Substring with Concatenation of All Words in C++ LeetCode 30 · sliding window · frequency maps · string_view Table of Contents Problem Statement Approach Algorithm C++ Program Input Sample Output Output Explanation Dry Run Flow of Execution Time Complexity Space Complexity Applications Key Points Interview Questions Frequently Asked Questions Conclusion Problem Statement 30. Substring with Concatenation of All Words Given a string s and an array of strings words , where every word has the same length, find all starting indices of substrings that are a concatenation of every word exactly once, in any order. Approach This solution uses a sliding window and two frequency maps. Since every word has the same length, the string is checked in chunks of len characters. freq stores the required frequency of each word. temp stores the frequencies in the current window. count tracks the number of word-sized chunks in the window. If a word occurs too ...
C Triangle Pattern Programs 2: Star, Number, Alphabet & Binary Patterns with Output
π’ C Program to Print Continuous Number Triangle Pattern
#include <stdio.h>
int main()
{
int num, k = 0;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
for(int j=i;j<=num;j++)
{
printf("%d ",k++);
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
0 1 2 3 4
5 6 7 8
9 10 11
12 13
14
π’ C Program to Print Repeated Binary Triangle Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
for(int j=i;j<=num;j++)
{
printf("%d ",i%2);
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
1 1 1 1 1
0 0 0 0
1 1 1
0 0
1
π’ C Program to Print Binary Number Triangle Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
for(int j=i;j<=num;j++)
{
printf("%d ",j%2);
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
1 0 1 0 1
0 1 0 1
1 0 1
0 1
1
⭐ C Program to Print Inverted Star Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
for(int j=i;j<=num;j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
* * * * *
* * * *
* * *
* *
*
π€ C Program to Print Reverse Repeated Alphabet Triangle Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=num;i>=1;i--)
{
for(int j=i;j>=1;j--)
{
printf("%c ",i+64);
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
E E E E E
D D D D
C C C
B B
A
π€ C Program to Print Reverse Alphabet Triangle Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=num;i>=1;i--)
{
for(int j=i;j>=1;j--)
{
printf("%c ",j+64);
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
E D C B A
D C B A
C B A
B A
A
π€ C Program to Print Repeated Alphabet Triangle Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
for(int j=i;j<=num;j++)
{
printf("%c ",i+64);
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
A A A A A
B B B B
C C C
D D
E
π€ C Program to Print Alphabet Triangle Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
for(int j=i;j<=num;j++)
{
printf("%c ",j+64);
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
A B C D E
B C D E
C D E
D E
E
π’ C Program to Print Repeated Number Triangle Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
for(int j=i;j<=num;j++)
{
printf("%d ",i);
}
printf("\n");
}
return 0;
}
π‘ Sample Output (Input: 5)
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
π’ C Program to Print Descending Number Pattern
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
for(int j=i;j<=num;j++)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
π Explanation:
This C program prints a descending number pattern using nested loops.
The outer loop controls the rows, while the inner loop prints numbers
starting from the current row number up to the entered number.
Comments
Post a Comment