- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 34469 Articles for Programming
![Asif Rahaman](https://www.tutorialspoint.com/assets/profiles/616697/profile/60_2108550-1678682669.jpg)
65 Views
Strings are important data types in any programming language. They are sequences of characters. Finding kth valid String is a programming technique in which we need to find the kth element out of a list of elements which is a valid String. In this article we will understand several methods like brute force, using list comprehensions and enumerate objects, filter method etc. We will also see how to use the Pandas library to deal with the same. Understanding The Problem Statement We will have list and the value of k as the input: list: ["", "orange", "75", "apple"] k: ... Read More
![Asif Rahaman](https://www.tutorialspoint.com/assets/profiles/616697/profile/60_2108550-1678682669.jpg)
96 Views
Finding the Kth index tuple list is an important programming concept in Python. The problem statement is that we need to find the mean of all the elements present at the kth index of the tuple elements. The tuples would be aggregated into a list data type. Throughout this article, we will adopt different approaches like using a while loop, list comprehension, and libraries like Pandas, NumPy, Statistics, etc. Understanding The Problem Statement Our input should contain a list of tuples and the value of k. list: [(1, 2, 3), (4, 5, 6), (7, 8, 9)] k: ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
352 Views
Problem Statement We have given a positive integer num. We need to find the lexicographically largest string of lowercase alphabetical characters such that the sum of all characters of the string is equal to num. Here, ‘a’ = 1, ‘b’ = 2, ‘c’ = 3, ‘d’ = 4, …., ‘z’ = 26. We need to use the ‘z’ characters at the string's start to create the largest lexicographical string. At last, we need to use the last character according to the num % 26 value. Sample Examples Input num = 30 Output ‘zd’ Explanation The ‘zd’ is the ... Read More
![Asif Rahaman](https://www.tutorialspoint.com/assets/profiles/616697/profile/60_2108550-1678682669.jpg)
94 Views
Finding the kth digit sum means we must find the sum of all the digits at the kth index of a list of numbers. This is an important programming concept, and we use this in data validation, financial analysis, etc. In this article, we will explore how to find the kth digit sum with the help of several custom methods like loops, list comprehensions, lambda, map functions, etc. We will also use libraries like Numpy and Functool to achieve the same. Understanding The Problem Statement Suppose we have the following inputs: list: [12, 73, 64] k=0 ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
267 Views
Problem Statement We have given binary string str of length N. We need to find all permutations of the string, convert them to the decimal value, and return all unique decimal values. Sample Examples Input str = ‘1’ Output [1] Explanation All permutations of the ‘1’ is only ‘1’. So, the decimal value related to ‘1’ equals 1. Input str = ‘10’ Output [1, 2] Explanation The permutations of ‘10’ are only ‘01’ and ‘10’, equivalent to 1 and 2, respectively. Input ‘101’ Output [3, 5, 6] Explanation All possible permutations of ‘101’ are ... Read More
![Asif Rahaman](https://www.tutorialspoint.com/assets/profiles/616697/profile/60_2108550-1678682669.jpg)
87 Views
List is an important data type in Python that can hold sequence of either homogeneous or heterogeneous data types. They are mutable. Finding the k summation from two lists means we need to find the combinations of the elements of two lists, which can add up to make the sum exactly equal to k. In this article, we will first explore the brute force method. Next, we would look into several optimized algorithms like two pointer approach, hashing algorithms, list comprehensions, etc. Using The Brute Force Method Brute force is the simplest approach. We write the logic without considering ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
49 Views
Problem Statement We have given a two-dimensional array containing the pairs of starting and ending times for time intervals in the 12-hour format. Also, we have given string str in the 12-hour time format. We need to find a total number of intervals which included the time represented by str. Sample Examples Input arr[][2] = {{“12:02:AM”, “10:55:PM”}, {“12:51:AM”, “11:40:AM”}, {“01:30:AM”, “12:00:PM”}, {“11:57:PM”, “11:59:PM”}}, str = “2:30:AM” Output 3 Explanation The time “2:30:AM” intersects the first three intervals. Input arr[][2] = {{“01:02:PM”, “10:55:PM”}, {“01:30:AM”, “11:00:AM”}}, str = “11:30:PM” Output 0 Explanation The ... Read More
![Asif Rahaman](https://www.tutorialspoint.com/assets/profiles/616697/profile/60_2108550-1678682669.jpg)
308 Views
The list is a popular mutable data type in Python that can hold heterogeneous data. We can access the list elements by using a process called indexing. The indexing means the distance of any element from the first element; hence it starts from 0. This article will explore how to find the k maximum elements and index number. We will achieve this through several methods like brute force, recursion, heapq module, Numpy library, enumerate functions, etc. We will also explore the time and space complexity of the algorithms used. Using The Brute Force Method Brute force is the simplest ... Read More
![Asif Rahaman](https://www.tutorialspoint.com/assets/profiles/616697/profile/60_2108550-1678682669.jpg)
214 Views
Matrix is a popular data representation technique in mathematics, machine modeling, etc. They are designed to deal with linear functions. Matrix initialization is a process to fill up the elements (rows and columns) of the matrix with either random or some predetermined values. After initialization there should be no undefined entries in the matrix. Initializing the matrix is one of the essential tasks in several fields, like competitive programming, machine and deep learning algorithms. In this article, we will learn how to initialize the matrix using various methods like loops, Numpy arrays, etc. We would also explore different types of ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
159 Views
Problem Statement We have given string str and a binary string B. The length of both strings is equal to the N. We need to check if we can make string str palindromic by swapping the characters of it multiple times at any pair of indices that contains unequal characters in string B. Sample Examples Input str = ‘AAS’ B = ‘101’ Output ‘YES’ Explanation We can swape the str[1] and str[2] as B[1] and B[2] are not equal. The final string can be ‘ASA’. Input str = ‘AASS’ B = ‘1111’ Output ‘No’ Explanation ... Read More