Check if Two Expressions With Brackets are Same

Given two strings s1 and s2 representing expressions containing addition operator, subtraction operator, lowercase alphabets, and parenthesis. Check if two expressions with brackets are the same. Example Input  s1 = “-(a+b+c)” s2 = “-a-b-c” Output  Yes Input  s1 = “a-b-(c-d)” s2 = “a-b-c-d” Output No Algorithm to Check if Two …

Read more

Longest Palindromic Subsequence

In the longest palindromic subsequence problem we have given a string, find the length of the longest palindromic subsequence. Examples Input: TUTORIALCUP Output: 3 Input: DYNAMICPROGRAMMING Output: 7 Naive Approach for Longest Palindromic Subsequence The naive approach to solve the above problem is to generate all the subsequences of the …

Read more

String Methods Java

In Java programming language, a string is nothing but a sequence of characters. It is the most widely used object. Java String class has many methods that are used for various manipulations. It is immutable, meaning, its value cannot be changed. A string is equivalent to an array of characters. …

Read more

Java string format

Java string format String.format() method in Java returns a formatted string value based on locale, format, and arguments passed. If we do not specify the locale, it takes the default locale from Locale.getDefault(). The extra arguments will be ignored if more arguments are passed. This method is similar to sprintf() …

Read more

Fizz Buzz

The problem name might seem fuzzy. Fizz Buzz is a game with which children are taught about the division. So, without much hassle let’s clear the buzz around it. Problem Statement Let us write a program where for multiples of 3 you print “Fizz”, for the multiples of 5 “Buzz” …

Read more

Translate »