Posts

Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[ 0 ] + nums[ 1 ] = 2 + 7 = 9, return [ 0 , 1 ]. Java script /** * @param {number[]} nums * @param {number} target * @return {number[]} */ var twoSum = function(nums, target) { const comp = {}; for(let i=0; i<nums.length; i++){ if(comp[nums[i] ]>=0){ return [ comp[nums[i] ] , i] } comp[target-nums[i]] = i } };   Java public int[] twoSum(int[] nums, int target) { for (int i = 0; i < nums.length; i++) { for (int j = i + 1; j < nums.length; j++) { if (nums[j] == target - nums[i]) { return new int[] { i, j }; } } } throw new IllegalArgumentException("No two sum solution")...

Longest Valid Parentheses

Image
 Longest Valid Parentheses (100 Marks) Source: Techgig Challenge Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Input Format Input 1: "(()" Input 2: ")()())" Constraints NA Output Format For Input 1, The longest valid parentheses sub-string is "()" For Input 2, The longest valid parentheses sub-string is "()()" Sample TestCase 1  : Input "()(()))))" Output 6  SOLUTION Java8 /* * Enter your code here. Read input from STDIN. Print your output to STDOUT. * Your class should be named CandidateCode. */ import java.io.*; import java.util.*; public class CandidateCode { public static void main(String args[] ) throws Exception {      //Write code here Scanner scan = new Scanner ( System.in ); ...

Oracle Apps: Create value set using API

Anonymous block to create a value set using fnd_flex_val_api.create_valueset_independent DECLARE value_set_name         VARCHAR2 (200); description         VARCHAR2 (200); security_available     VARCHAR2 (200); enable_longlist     VARCHAR2 (200); format_type         VARCHAR2 (200); maximum_size        NUMBER; PRECISION         NUMBER; numbers_only         VARCHAR2 (200); uppercase_only         VARCHAR2 (200); right_justify_zero_fill VARCHAR2 (200); min_value         VARCHAR2 (200); max_value         VARCHAR2 (200); v_session_mode         VARCHAR2 (20) := 'customer_data'; x             VARCHAR2 (200); v_msg ...

Oracle Apps: Add value to independent value set

assigning a value to the independent value set using FND_FLEX_VALUE_PKG.LOAD_ROW Api. DECLARE    v_enabled_flag         VARCHAR2 (2)              := 'Y';    v_summary_flag         VARCHAR2 (2)              := 'Y';    v_start_date_active    DATE                      := SYSDATE;    v_error_msg            VARCHAR2 (1000)           := NULL;    v_who_type             fnd_flex_loader_apis.who_type;    v_request_id    ...

Oracle Apps: Add Responsibility to User

Adding a Responsibility to an Oracle User in R12 Oracle Apps using API -- FND_USER_PKG.ADDRESP to add responsibility ‘System Administrator’ for the user ‘USERZEE’ using the API. DECLARE    v_user_name              VARCHAR2 (100) := 'USERZEE';    v_responsibility_name    VARCHAR2 (100) := 'System Administrator';    v_application_name       VARCHAR2 (100) := NULL;    v_responsibility_key     VARCHAR2 (100) := NULL;    v_security_group         VARCHAR2 (100) := NULL;    v_description            VARCHAR2 (100) := NULL; BEGIN    SELECT fa.application_short_name,                  fr.responsibility_key, ...

TCA Architecture Oracle Customer Interface Joins

Image