Found 33676 Articles for Programming

How to conduct Grid search using python?

Jay Singh
Updated on 31-Jul-2023 19:02:10

232 Views

Optimizing hyper parameters in machine learning models requires the use of grid search. Model performance is greatly influenced by hyper parameters like regularization strength or learning rate. With grid search, a preset set of hyper parameters is methodically investigated to identify the configuration that produces the best outcomes. Grid search offers an easy-to-use interface for building a grid of hyper parameters and evaluating model performance via cross-validation, both of which can be done using Python's Scikit-learn module. Grid search automates the search for ideal hyper parameters, allowing machine learning practitioners to concentrate on crucial activities like feature engineering and model ... Read More

Count pairs of characters in a string whose ASCII value difference is K

Sonal Meenu Singh
Updated on 31-Jul-2023 19:50:15

165 Views

In this tutorial, we learn how to count the character pair in a string whose ASCII value is the difference of K. K is any difference value, it can be either 1 or 0. Create a C++ code to count such character pairs in an input string S. We used the size() method of the String class Syntax size() = It is a String class method. It is an empty parameter library method. It returns the size of the string in terms of bytes. string_name.size() Example = s.size() ASCII values are predefined values for characters, symbols, ... Read More

Count of three non-overlapping substrings which on concatenation forms a palindrome

Sonal Meenu Singh
Updated on 31-Jul-2023 19:48:53

145 Views

Introduction In this tutorial, we will elaborate an approach for finding three non-overlapping substrings from a given string s, and when all substrings are combined together they form a palindrome. To solve this task we use the string class features of the C++ programming language. Palindrome in a string means the string reads the same in both forward and backward directions. The palindrome string example is Madam. Suppose there is a string "s" and the substrings are a, b, and c. When you combine a, b, and c, they form a palindrome string. Here is an example to understand the ... Read More

Double floatValue() in Java with Examples

Way2Class
Updated on 31-Jul-2023 17:27:27

144 Views

When it comes to dealing with precision-based calculations, Java provides a myriad of tools and functions. One such functionality is the handling of floating-point numbers, particularly with the Double and Float wrapper classes. Today, we are going to unravel the mysteries around the Double and Float Value() method in Java. Syntax The Value() function in the Double and Float classes in Java is defined as follows: public double doubleValue() public float floatValue() Explanation of Syntax These techniques are a piece of the Twofold and Float covering classes. The doubleValue() technique changes over the Twofold item into a twofold crude, ... Read More

Count occurrence of a given character in a string using Stream API in Java

Sonal Meenu Singh
Updated on 31-Jul-2023 19:47:33

7K+ Views

Introduction In this tutorial, we will implement an approach that counts how many times a particular character appears in a string using the Stream API in Java. A string is a collection of characters and we will use a String class method to separate string characters. We will take an input string and define a character we want to count. The functions used in this approach are the chars() method of the String class and the filter() method of the Stream interface. char() = It is a String class instance method. It returns the intstream values. The stream contains ... Read More

Print first and last character of each word in a string

Mallika Gupta
Updated on 31-Jul-2023 17:49:26

1K+ Views

Introduction A C++ string is contiguous storage of alphanumeric characters as well as special characters. A string has the following properties − Every C++ string is associated with a fixed length. Character operations can be easily performed with the string characters. A string is composed of words, which are space separated. In this article, we are going to develop a code that takes as input a string, and displays the last character of each word in the string. Let us look at the following example to understand the topic better − Sample Example Example 1 − str − ... Read More

Pairs of strings which on concatenating contains each character of “string”

Mallika Gupta
Updated on 31-Jul-2023 17:42:45

123 Views

Introduction A stream of characters flowing together collectively comprising of alphanumeric characters as well as special symbols can be termed as a C++ string. String concatenation is an important aspect of the string data structure, since it is used to combine different sub strings or words to form complete sentences. Concatenation in C++ can be simply done using the + operator. In this article, we are going to develop a code that takes as input an array of string, and then analyses each pair to see if that pair contains all the letters of the word “string” . Let us ... Read More

Print last character of each word in a string

Mallika Gupta
Updated on 31-Jul-2023 17:46:19

1K+ Views

Introduction C++ strings are essentially a combination of words used as a storage unit to contain alphanumeric data. The words in a string are associated with the following properties − The word positions begin with 0. Every word is associated with a different length. The characters combine together to form words, which eventually form sentences. By default, the words are separated by a space character. Every word contains at least one character. In this article, we are going to develop a code that takes as input a string, and displays the last character of each word in ... Read More

Longest double string of a Palindrome

Aishwarya Naglot
Updated on 05-Nov-2024 15:01:01

115 Views

A contiguous sequence of characters, consisting of uppercase, lowercase, repetitive, or unique alphanumeric characters, forms a C++ string. Each string has a unique length, which may be either odd or even in nature. Longest Double String of a Palindrome A Palindromic string is a sequence of characters that reads the same from both the beginning and the end. In other words, characters at equivalent positions from the start and end have no difference. These palindromes can either have an even length or an odd length. The odd-length palindrome features a middle character separating the two equivalent halves. In this article, ... Read More

Count of strings satisfying the given conditions

Mallika Gupta
Updated on 31-Jul-2023 17:28:44

165 Views

Introduction A string in C++ is also a primitive data type which is comprised of alphanumeric characters. The letters in a string are case sensitive, but strings can contain both upper and lower case. In this article, we are given an input array of lowercase strings, and require the count of the pair of strings from the array satisfying the following conditions − Both the strings should have the same first and last vowel Both the strings have an equal number of pairs An array is a data structure simulating the storage of similar elements. A C++ array ... Read More

Advertisements