Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 564 of 2547
Decoded String at Index in Python
The Decoded String at Index problem involves finding a character at a specific position in a decoded string without actually creating the full decoded string. This approach saves memory when dealing with very long decoded strings. Problem Understanding Given an encoded string, we decode it using these rules ? If the character is a letter, write it to the tape. If the character is a digit, repeat the entire current tape digit − 1 more times. For example, "hello2World3" becomes "hellohelloWorldhellohelloWorldhellohelloWorld". Algorithm Overview Instead of creating the full decoded string, we use ...
Read MoreKth Smallest Element in a Sorted Matrix in Python
Finding the Kth smallest element in a sorted matrix is a classic problem that can be solved efficiently using binary search. In this problem, we have an n x n matrix where each row and column is sorted in increasing order, and we need to find the kth smallest element in the entire matrix. Problem Understanding Given a matrix where rows and columns are sorted in ascending order, we need to find the kth smallest element. For example, in the matrix [[1, 5, 9], [10, 11, 13], [12, 13, 15]], if k=8, the answer is 13 because when ...
Read MoreSurrounded Regions in Python
The Surrounded Regions problem involves capturing all regions of 'O' that are completely surrounded by 'X' on a 2D board. A region is considered surrounded if all 'O' cells are enclosed by 'X' cells and cannot reach the board's border. Problem Understanding Given a 2D board with 'X' and 'O' characters, we need to capture surrounded regions by flipping all 'O' to 'X'. However, 'O' cells connected to the border should remain unchanged ? Input Board Output Board XXXX XOOX XXOX XOXX XXXX XXXX XXXX XOXX ...
Read MoreMinimum Path Sum in Python
The minimum path sum problem involves finding a path from the top-left corner to the bottom-right corner of a matrix that minimizes the sum of all numbers along the path. You can only move down or right at any point. Problem Example Given this matrix: 1 3 1 1 5 1 4 2 1 The optimal path is: 1 → 3 → 1 → 1 → 1, giving a minimum sum of 7. Algorithm Steps The dynamic programming approach works as follows: Fill the ...
Read MoreCalculating Wind Chill Factor(WCF) or Wind Chill Index(WCI) in Python Program
In this tutorial, we will learn how to calculate the Wind Chill Factor (WCF) or Wind Chill Index (WCI) in Python. The wind chill index measures how cold it feels when wind is factored in with the actual air temperature. Wind Chill Formula We use the following standard formula to calculate the Wind Chill Index ? Twc = 13.12 + 0.6215Ta − 11.37v0.16 + 0.3965Tav0.16 Where: Twc = Wind Chill Index (in degrees Celsius) Ta = Air Temperature (in degrees Celsius) v = Wind Speed (in kilometers per hour) Implementation Steps Follow ...
Read MoreLambda expression in Python Program to rearrange positive and negative numbers
In this tutorial, we will write an anonymous function using lambda to rearrange positive and negative numbers in a list. The goal is to place all negative numbers first, followed by all positive numbers. Algorithm Let's see how to solve the problem step by step ? 1. Initialize a list with negative and positive numbers. 2. Write a lambda expression that takes a list as an argument. 2.1. Iterate over the list and get negative numbers 2.2. Same for positive numbers 2.3. Combine both using concatenation operator. ...
Read MorePython Dictionary Comprehension
In this tutorial, we are going to learn how to use dictionary comprehensions in Python. If you are already familiar with list comprehension, then it won't take much time to learn dictionary comprehensions. Dictionary comprehension provides a concise way to create dictionaries using a single line of code. We need key-value pairs to create a dictionary. The general syntax of dictionary comprehension is: {key: value for item in iterable} Basic Dictionary Comprehension Let's see how to generate numbers as keys and their squares as values within the range of 10. Our result should look ...
Read MoreProgram to print its script name as output in Python
In this tutorial, we are going to write a program that prints the name of the Python script file. We can find the script name using the sys module. The sys module stores all the command line arguments of the python command in the sys.argv list. The first element in the list is the script name. We can extract it from that list. Python makes it easy. Getting Script Name Only To print just the script filename without the full path ? import sys import os # Get just the filename script_name = os.path.basename(sys.argv[0]) ...
Read MoreDifference between Python and Ruby
Python and Ruby are both popular high-level programming languages with distinct characteristics and use cases. Python, created by Guido van Rossum in 1989, emphasizes simplicity and readability. Ruby, developed by Yukihiro Matsumoto in 1995, follows the principle of programmer happiness with flexible syntax. What is Python? Python is an object-oriented, dynamic, interpreted language known for its clean syntax and powerful capabilities. High-level data structures, dynamic typing, and binding make it an excellent choice for rapid application development and scripting. Python's straightforward syntax reduces program maintenance costs. Its modular approach through packages and modules promotes code reusability. The ...
Read MoreBypass Anti-virus using Veil Framework
This article demonstrates how to bypass antivirus detection using the Veil Framework, a collection of penetration testing tools. The framework consists of several modules designed for payload generation and evasion techniques. Veil Framework Components The Veil Framework includes the following key modules − Veil-Evasion − generates antivirus-evading payloads using various techniques and programming languages Veil-Catapult − a psexec-style payload delivery system that integrates with Veil-Evasion Veil-PowerView − a PowerShell tool for network reconnaissance on Windows domains Veil-Pillage − a modular post-exploitation framework integrated with ...
Read More