データ構造とアルゴリズム
問題 与えられたコード 解答コード 学習メモ 問題 leetcode.com 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 m…
AIZU ONLINE JUDGEより、二分探索に関する問題(ALDS1_4_B)をpythonで解いていきます。 onlinejudge.u-aizu.ac.jp 問題自体は線形探索の時と同様ですが、入力値のn,qの最大値が増えているため線形探索で解答するとTLEとなります。 ちなみにsetクラスならこち…
AIZU ONLINE JUDGEより、線形探索に関する問題(ALDS1_4_A)をpythonで解いていきます。 onlinejudge.u-aizu.ac.jp setクラスを用いて実装 n = int(input()) s = list(map(int,input().split())) q = int(input()) t = list(map(int,input().split())) temp = …